no message

This commit is contained in:
Ioannis Kalyvas 2018-10-02 17:33:58 +03:00
parent f2bfd402f8
commit e0c302e67e
148 changed files with 1952 additions and 872 deletions

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ final/
temp/ temp/
*.jar *.jar
*.lst *.lst
dmp-frontend/.vscode/

View File

@ -0,0 +1,46 @@
package eu.eudat.data.converters;
import org.springframework.format.datetime.DateFormatter;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
/**
* Created by ikalyvas on 9/25/2018.
*/
@Converter
public class DateToUTCConverter implements AttributeConverter<Date, Date> {
@Override
public Date convertToDatabaseColumn(Date attribute) {
if(attribute == null) return null;
DateFormat formatterIST = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
formatterIST.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
String date = formatterIST.format(attribute);
return formatterIST.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
@Override
public Date convertToEntityAttribute(Date dbData) {
if(dbData == null) return null;
DateFormat formatterIST = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
formatterIST.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
String date = formatterIST.format(dbData);
return formatterIST.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,49 @@
package eu.eudat.data.dao.criteria;
import eu.eudat.data.entities.Dataset;
import eu.eudat.types.project.ProjectStateType;
import java.util.List;
import java.util.UUID;
/**
* Created by ikalyvas on 10/2/2018.
*/
public class DatasetPublicCriteria extends Criteria<Dataset>{
public ProjectStateType projectStatus;
public List<UUID> projects;
public List<UUID> datasetProfile;
public List<String> dmpOrganisations;
public ProjectStateType getProjectStatus() {
return projectStatus;
}
public void setProjectStatus(ProjectStateType projectStatus) {
this.projectStatus = projectStatus;
}
public List<UUID> getProjects() {
return projects;
}
public void setProjects(List<UUID> projects) {
this.projects = projects;
}
public List<UUID> getDatasetProfile() {
return datasetProfile;
}
public void setDatasetProfile(List<UUID> datasetProfile) {
this.datasetProfile = datasetProfile;
}
public List<String> getDmpOrganisations() {
return dmpOrganisations;
}
public void setDmpOrganisations(List<String> dmpOrganisations) {
this.dmpOrganisations = dmpOrganisations;
}
}

View File

@ -4,6 +4,7 @@ import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.jpa.hibernatequeryablelist.QueryableHibernateList; import eu.eudat.queryable.jpa.hibernatequeryablelist.QueryableHibernateList;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;

View File

@ -5,6 +5,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Content; import eu.eudat.data.entities.Content;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.UUID; import java.util.UUID;
@ -27,6 +28,7 @@ public class ContentDaoImpl extends DatabaseAccess<Content> implements ContentDa
} }
@Override @Override
@Async
public CompletableFuture<Content> createOrUpdateAsync(Content item) { public CompletableFuture<Content> createOrUpdateAsync(Content item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }

View File

@ -10,6 +10,7 @@ import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
@ -78,6 +79,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
return this.getDatabaseService().getQueryable(DMP.class); return this.getDatabaseService().getQueryable(DMP.class);
} }
@Async
@Override @Override
public CompletableFuture<DMP> createOrUpdateAsync(DMP item) { public CompletableFuture<DMP> createOrUpdateAsync(DMP item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DMPProfile; import eu.eudat.data.entities.DMPProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.UUID; import java.util.UUID;
@ -22,6 +23,7 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
super(databaseService); super(databaseService);
} }
@Async
@Override @Override
public CompletableFuture<DMPProfile> createOrUpdateAsync(DMPProfile item) { public CompletableFuture<DMPProfile> createOrUpdateAsync(DMPProfile item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DataRepository; import eu.eudat.data.entities.DataRepository;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -38,6 +39,7 @@ public class DataRepositoryDaoImpl extends DatabaseAccess<DataRepository> implem
} }
@Override @Override
@Async
public CompletableFuture<DataRepository> createOrUpdateAsync(DataRepository item) { public CompletableFuture<DataRepository> createOrUpdateAsync(DataRepository item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }

View File

@ -9,6 +9,7 @@ import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
@ -76,6 +77,7 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
return this.getDatabaseService().getQueryable(Dataset.class); return this.getDatabaseService().getQueryable(Dataset.class);
} }
@Async
public CompletableFuture<Dataset> createOrUpdateAsync(Dataset item) { public CompletableFuture<Dataset> createOrUpdateAsync(Dataset item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
} }

View File

@ -6,6 +6,7 @@ import eu.eudat.data.entities.DatasetExternalDataset;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -33,6 +34,7 @@ public class DatasetExternalDatasetDaoImpl extends DatabaseAccess<DatasetExterna
} }
@Override @Override
@Async
public DatasetExternalDataset find(UUID id) { public DatasetExternalDataset find(UUID id) {
return getDatabaseService().getQueryable(DatasetExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle(); return getDatabaseService().getQueryable(DatasetExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
} }

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DatasetProfile; import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -52,6 +53,7 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
return this.getDatabaseService().getQueryable(DatasetProfile.class); return this.getDatabaseService().getQueryable(DatasetProfile.class);
} }
@Async
@Override @Override
public CompletableFuture<DatasetProfile> createOrUpdateAsync(DatasetProfile item) { public CompletableFuture<DatasetProfile> createOrUpdateAsync(DatasetProfile item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -7,6 +7,7 @@ import eu.eudat.data.entities.DatasetProfile;
import eu.eudat.data.entities.DatasetService; import eu.eudat.data.entities.DatasetService;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -28,6 +29,7 @@ public class DatasetServiceDaoImpl extends DatabaseAccess<DatasetService> implem
return this.getDatabaseService().createOrUpdate(item, DatasetService.class); return this.getDatabaseService().createOrUpdate(item, DatasetService.class);
} }
@Async
@Override @Override
public CompletableFuture<DatasetService> createOrUpdateAsync(DatasetService item) { public CompletableFuture<DatasetService> createOrUpdateAsync(DatasetService item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.ExternalDataset; import eu.eudat.data.entities.ExternalDataset;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -48,6 +49,7 @@ public class ExternalDatasetDaoImpl extends DatabaseAccess<ExternalDataset> impl
return this.getDatabaseService().getQueryable(ExternalDataset.class); return this.getDatabaseService().getQueryable(ExternalDataset.class);
} }
@Async
@Override @Override
public CompletableFuture<ExternalDataset> createOrUpdateAsync(ExternalDataset item) { public CompletableFuture<ExternalDataset> createOrUpdateAsync(ExternalDataset item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Invitation; import eu.eudat.data.entities.Invitation;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.UUID; import java.util.UUID;
@ -45,6 +46,7 @@ public class InvitationDaoImpl extends DatabaseAccess<Invitation> implements Inv
return this.getDatabaseService().getQueryable(Invitation.class); return this.getDatabaseService().getQueryable(Invitation.class);
} }
@Async
@Override @Override
public CompletableFuture<Invitation> createOrUpdateAsync(Invitation item) { public CompletableFuture<Invitation> createOrUpdateAsync(Invitation item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Organisation; import eu.eudat.data.entities.Organisation;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -47,6 +48,7 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
return this.getDatabaseService().getQueryable(Organisation.class); return this.getDatabaseService().getQueryable(Organisation.class);
} }
@Async
@Override @Override
public CompletableFuture<Organisation> createOrUpdateAsync(Organisation item) { public CompletableFuture<Organisation> createOrUpdateAsync(Organisation item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -8,6 +8,7 @@ import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.types.project.ProjectStateType; import eu.eudat.types.project.ProjectStateType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.persistence.criteria.JoinType; import javax.persistence.criteria.JoinType;
@ -71,6 +72,7 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
return query; return query;
} }
@Async
@Override @Override
public CompletableFuture<Project> createOrUpdateAsync(Project item) { public CompletableFuture<Project> createOrUpdateAsync(Project item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Registry; import eu.eudat.data.entities.Registry;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -47,6 +48,7 @@ public class RegistryDaoImpl extends DatabaseAccess<Registry> implements Registr
return this.getDatabaseService().getQueryable(Registry.class); return this.getDatabaseService().getQueryable(Registry.class);
} }
@Async
@Override @Override
public CompletableFuture<Registry> createOrUpdateAsync(Registry item) { public CompletableFuture<Registry> createOrUpdateAsync(Registry item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Researcher; import eu.eudat.data.entities.Researcher;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -49,6 +50,7 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
return this.getDatabaseService().getQueryable(Researcher.class); return this.getDatabaseService().getQueryable(Researcher.class);
} }
@Async
@Override @Override
public CompletableFuture<Researcher> createOrUpdateAsync(Researcher item) { public CompletableFuture<Researcher> createOrUpdateAsync(Researcher item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.Service; import eu.eudat.data.entities.Service;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -47,6 +48,7 @@ public class ServiceDaoImpl extends DatabaseAccess<Service> implements ServiceDa
return this.getDatabaseService().getQueryable(Service.class); return this.getDatabaseService().getQueryable(Service.class);
} }
@Async
@Override @Override
public CompletableFuture<Service> createOrUpdateAsync(Service item) { public CompletableFuture<Service> createOrUpdateAsync(Service item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -5,6 +5,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.UserDMP; import eu.eudat.data.entities.UserDMP;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -41,6 +42,7 @@ public class UserDmpDaoImpl extends DatabaseAccess<UserDMP> implements UserDmpDa
return this.getDatabaseService().getQueryable(UserDMP.class); return this.getDatabaseService().getQueryable(UserDMP.class);
} }
@Async
@Override @Override
public CompletableFuture<UserDMP> createOrUpdateAsync(UserDMP item) { public CompletableFuture<UserDMP> createOrUpdateAsync(UserDMP item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.UserInfo; import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.UUID; import java.util.UUID;
@ -51,6 +52,7 @@ public class UserInfoDaoImpl extends DatabaseAccess<UserInfo> implements UserInf
return this.getDatabaseService().getQueryable(UserInfo.class); return this.getDatabaseService().getQueryable(UserInfo.class);
} }
@Async
@Override @Override
public CompletableFuture<UserInfo> createOrUpdateAsync(UserInfo item) { public CompletableFuture<UserInfo> createOrUpdateAsync(UserInfo item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -7,6 +7,7 @@ import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.entities.UserRole; import eu.eudat.data.entities.UserRole;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
@ -57,6 +58,7 @@ public class UserRoleDaoImpl extends DatabaseAccess<UserRole> implements UserRol
return this.getDatabaseService().getQueryable(UserRole.class); return this.getDatabaseService().getQueryable(UserRole.class);
} }
@Async
@Override @Override
public CompletableFuture<UserRole> createOrUpdateAsync(UserRole item) { public CompletableFuture<UserRole> createOrUpdateAsync(UserRole item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));

View File

@ -4,6 +4,7 @@ import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
@ -143,4 +144,10 @@ public class Content implements DataEntity<Content, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Content buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,9 +1,11 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -33,9 +35,13 @@ public class Credential implements DataEntity<Credential,UUID> {
private String publicValue; private String publicValue;
@Column(name = "\"Secret\"", nullable = false) @Column(name = "\"Secret\"", nullable = false)
private String secret; private String secret;
@Column(name = "\"CreationTime\"", nullable = false) @Column(name = "\"CreationTime\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date creationTime; private Date creationTime;
@Column(name = "\"LastUpdateTime\"", nullable = false) @Column(name = "\"LastUpdateTime\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date lastUpdateTime; private Date lastUpdateTime;
@Column(name = "\"ExternalId\"", nullable = false) @Column(name = "\"ExternalId\"", nullable = false)
@ -140,4 +146,10 @@ public class Credential implements DataEntity<Credential,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Credential buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,12 +1,14 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Entity @Entity
@ -15,7 +17,7 @@ import java.util.*;
@NamedEntityGraph( @NamedEntityGraph(
name = "dataManagementPlanListingModel", name = "dataManagementPlanListingModel",
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"),
@NamedAttributeNode("project"),@NamedAttributeNode("users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")} @NamedAttributeNode("project"), @NamedAttributeNode("users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")}
), ),
@NamedEntityGraph( @NamedEntityGraph(
name = "fullyDetailed", name = "fullyDetailed",
@ -132,9 +134,11 @@ public class DMP implements DataEntity<DMP, UUID> {
private String dmpProperties; private String dmpProperties;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ -319,4 +323,11 @@ public class DMP implements DataEntity<DMP, UUID> {
return this.id; return this.id;
} }
@Override
public DMP buildFromTuple(List<Tuple> tuple, String base) {
this.id = tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id", UUID.class);
this.dataset = tuple.stream().map(x -> new Dataset().buildFromTuple(tuple, base.isEmpty() ? "dataset" : base + "." + "dataset")).collect(Collectors.toSet());
this.creator = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0);
return this;
}
} }

View File

@ -1,12 +1,14 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -39,9 +41,11 @@ public class DMPProfile implements DataEntity<DMPProfile, UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
public int getStatus() { public int getStatus() {
@ -111,4 +115,10 @@ public class DMPProfile implements DataEntity<DMPProfile, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DMPProfile buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -8,6 +8,7 @@ import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -145,4 +146,10 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,U
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DataRepository buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
@ -17,7 +18,7 @@ import java.util.stream.Collectors;
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"), attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}, @NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
subgraphs = { subgraphs = {
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")}), @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("project"),@NamedAttributeNode("organisations")}),
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}) @NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")})
}), }),
@ -126,9 +127,11 @@ public class Dataset implements DataEntity<Dataset, UUID> {
private boolean isPublic; private boolean isPublic;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@ -328,4 +331,10 @@ public class Dataset implements DataEntity<Dataset, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Dataset buildFromTuple(List<Tuple> tuple, String base) {
this.id = (UUID) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id");
return this;
}
} }

View File

@ -5,6 +5,7 @@ import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
/** /**
@ -32,7 +33,6 @@ public class DatasetDataRepository implements DataEntity<DatasetDataRepository,U
@Column(name = "\"Role\"") @Column(name = "\"Role\"")
private Integer role; private Integer role;
@Column(name = "\"Data\"") @Column(name = "\"Data\"")
private String data; private String data;
@ -87,4 +87,10 @@ public class DatasetDataRepository implements DataEntity<DatasetDataRepository,U
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DatasetDataRepository buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -5,6 +5,7 @@ import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -18,7 +19,6 @@ public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") @Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id; private UUID id;
@ManyToOne @ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false) @JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset; private Dataset dataset;
@ -85,4 +85,10 @@ public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DatasetExternalDataset buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,12 +1,14 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -37,9 +39,11 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created; private Date created;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@Column(name = "\"Description\"") @Column(name = "\"Description\"")
@ -135,4 +139,10 @@ public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DatasetProfile buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -7,6 +7,7 @@ import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -87,4 +88,10 @@ public class DatasetService implements DataEntity<DatasetService, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public DatasetService buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,10 +1,12 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -27,9 +29,11 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
private String reference; private String reference;
@Column(name = "\"Created\"", nullable = false) @Column(name = "\"Created\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date created; private Date created;
@Column(name = "\"Modified\"", nullable = false) @Column(name = "\"Modified\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date modified; private Date modified;
@OneToMany(mappedBy = "externalDataset", cascade = CascadeType.ALL, orphanRemoval = true) @OneToMany(mappedBy = "externalDataset", cascade = CascadeType.ALL, orphanRemoval = true)
@ -102,4 +106,10 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public ExternalDataset buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -5,6 +5,7 @@ import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -104,4 +105,10 @@ public class Invitation implements DataEntity<Invitation,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Invitation buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
@ -8,6 +9,7 @@ import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -53,9 +55,11 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ -155,4 +159,10 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Organisation buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,14 +1,17 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
@Entity @Entity
@ -109,9 +112,11 @@ public class Project implements DataEntity<Project, UUID> {
@Column(name = "\"StartDate\"", nullable = false) @Column(name = "\"StartDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date startdate = null; private Date startdate = null;
@Column(name = "\"EndDate\"", nullable = false) @Column(name = "\"EndDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date enddate = null; private Date enddate = null;
@ -140,6 +145,13 @@ public class Project implements DataEntity<Project, UUID> {
@JoinColumn(name = "\"Content\"") @JoinColumn(name = "\"Content\"")
private Content content; private Content content;
public Project() {
}
public Project(Project project) {
this.id = project.getId();
}
public String getDescription() { public String getDescription() {
return description; return description;
} }
@ -285,11 +297,17 @@ public class Project implements DataEntity<Project, UUID> {
this.enddate = entity.getEnddate(); this.enddate = entity.getEnddate();
this.modified = new Date(); this.modified = new Date();
if (entity.getContent() != null) this.content = entity.getContent(); if (entity.getContent() != null) this.content = entity.getContent();
//this.creationUser = entity.getCreationUser(); //TODO
} }
@Override @Override
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Project buildFromTuple(List<Tuple> tuple, String base) {
this.id = (UUID) tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id" );
this.dmps = tuple.stream().map(x-> new DMP().buildFromTuple(tuple,"dmps")).collect(Collectors.toSet());
return this;
}
} }

View File

@ -1,12 +1,14 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -50,9 +52,11 @@ public class Registry implements DataEntity<Registry,UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ -151,4 +155,10 @@ public class Registry implements DataEntity<Registry,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Registry buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,12 +1,14 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -52,9 +54,11 @@ public class Researcher implements DataEntity<Researcher,UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ -154,4 +158,10 @@ public class Researcher implements DataEntity<Researcher,UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Researcher buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,12 +1,13 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -46,9 +47,11 @@ public class Service implements DataEntity<Service, UUID> {
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "\"Modified\"") @Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date(); private Date modified = new Date();
@ -147,4 +150,10 @@ public class Service implements DataEntity<Service, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public Service buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -4,6 +4,7 @@ import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Entity @Entity
@ -94,4 +95,10 @@ public class UserDMP implements DataEntity<UserDMP, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public UserDMP buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,14 +1,12 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.*;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@Entity @Entity
@ -44,10 +42,12 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
@Column(name = "created", nullable = false) @Column(name = "created", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date created = null; private Date created = null;
@Column(name = "lastloggedin", nullable = true) @Column(name = "lastloggedin", nullable = true)
@Convert(converter = DateToUTCConverter.class)
private Date lastloggedin = null; private Date lastloggedin = null;
@ -177,4 +177,10 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public UserInfo buildFromTuple(List<Tuple> tuple, String base) {
this.id = (UUID) tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id" );
return this;
}
} }

View File

@ -4,6 +4,7 @@ import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*; import javax.persistence.*;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -57,4 +58,10 @@ public class UserRole implements DataEntity<UserRole, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.id; return this.id;
} }
@Override
public UserRole buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
} }

View File

@ -1,9 +1,11 @@
package eu.eudat.data.entities; package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -20,10 +22,12 @@ public class UserToken implements DataEntity<UserToken, UUID> {
private UserInfo user; private UserInfo user;
@Column(name = "\"IssuedAt\"", nullable = false) @Column(name = "\"IssuedAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date issuedAt = null; private Date issuedAt = null;
@Column(name = "\"ExpiresAt\"", nullable = false) @Column(name = "\"ExpiresAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date expiresAt = null; private Date expiresAt = null;
public UUID getToken() { public UUID getToken() {
@ -67,4 +71,10 @@ public class UserToken implements DataEntity<UserToken, UUID> {
public UUID getKeys() { public UUID getKeys() {
return this.token; return this.token;
} }
@Override
public UserToken buildFromTuple(List<Tuple> tuple, String base) {
this.token = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "token" : "token"));
return this;
}
} }

View File

@ -8,6 +8,16 @@ import eu.eudat.queryable.QueryableList;
import java.util.UUID; import java.util.UUID;
public class ProjectCriteriaRequest extends Query<ProjectCriteria,Project> { public class ProjectCriteriaRequest extends Query<ProjectCriteria,Project> {
private Integer length;
public Integer getLength() {
return length;
}
public void setLength(Integer length) {
this.length = length;
}
private ProjectCriteriaRequest() { private ProjectCriteriaRequest() {
} }

View File

@ -0,0 +1,38 @@
package eu.eudat.data.query.items.table.dataset;
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.definition.TableQuery;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import java.util.Arrays;
import java.util.UUID;
/**
* Created by ikalyvas on 10/2/2018.
*/
public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria, Dataset, UUID> {
@Override
public QueryableList<Dataset> applyCriteria() {
QueryableList<Dataset> query = this.getQuery();
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
if (this.getCriteria().projects != null && !this.getCriteria().projects.isEmpty())
query.where(((builder, root) -> root.get("dmp").get("project").get("id").in(this.getCriteria().projects)));
if (this.getCriteria().projectStatus != null) query
.where(((builder, root) -> builder.equal(root.get("dmp").get("project").get("status"), this.getCriteria().projectStatus.getValue())));
if (this.getCriteria().datasetProfile != null && !this.getCriteria().datasetProfile.isEmpty()) query
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().datasetProfile)));
if(this.getCriteria().dmpOrganisations != null && !this.getCriteria().dmpOrganisations.isEmpty())query
.where(((builder, root) -> root.join("dmp").join("organisations").get("reference").in(this.getCriteria().dmpOrganisations)));
return query;
}
@Override
public QueryableList<Dataset> applyPaging(QueryableList<Dataset> items) {
return null;
}
}

View File

@ -2,25 +2,27 @@ package eu.eudat.queryable.jpa.hibernatequeryablelist;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.exceptions.NotSingleResultException; import eu.eudat.queryable.exceptions.NotSingleResultException;
import eu.eudat.queryable.jpa.predicates.*; import eu.eudat.queryable.jpa.predicates.NestedQuerySinglePredicate;
import eu.eudat.queryable.jpa.predicates.OrderByPredicate;
import eu.eudat.queryable.jpa.predicates.SelectPredicate;
import eu.eudat.queryable.jpa.predicates.SinglePredicate;
import eu.eudat.queryable.queryableentity.DataEntity; import eu.eudat.queryable.queryableentity.DataEntity;
import eu.eudat.queryable.types.FieldSelectionType; import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField; import eu.eudat.queryable.types.SelectionField;
import org.springframework.scheduling.annotation.Async;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Tuple;
import javax.persistence.TypedQuery; import javax.persistence.TypedQuery;
import javax.persistence.criteria.*; import javax.persistence.criteria.*;
import java.util.Arrays; import java.util.*;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class QueryableHibernateList<T extends DataEntity> implements QueryableList<T> { public class QueryableHibernateList<T extends DataEntity> implements QueryableList<T> {
private EntityManager manager; private EntityManager manager;
private CriteriaQuery<T> query; private CriteriaQuery query;
private Class<T> tClass; private Class<T> tClass;
private Root<T> root; private Root<T> root;
private Root<T> nestedQueryRoot; private Root<T> nestedQueryRoot;
@ -57,15 +59,32 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
} }
private QueryableList<T> selectFields() { private QueryableList<T> selectFields() {
List<Selection> rootFields = fields.stream().map(field -> root.get(field)).collect(Collectors.toList()); List<Selection> rootFields = fields.stream().map(field -> this.convertFieldToPath(field)).collect(Collectors.toList());
this.query.select(this.manager.getCriteriaBuilder().construct(tClass, rootFields.toArray(new Selection[rootFields.size()]))); this.query.select(this.manager.getCriteriaBuilder().tuple(rootFields.toArray(new Selection[rootFields.size()])));
return this; return this;
} }
private Path convertFieldToPath(String field) {
if (!field.contains(".")) {
Path path = this.root.get(field);
path.alias(field);
return path;
} else {
String[] fields = field.split("\\.");
Path path = this.root.get(fields[0]);
Join join = null;
path.alias(fields[0]);
for (int i = 1; i < fields.length; i++) {
join = join != null ? join.join(fields[i - 1], JoinType.LEFT) : this.root.join(fields[i - 1], JoinType.LEFT) ;
path = join.get(fields[i]);
path.alias(String.join(".", Arrays.asList(fields).subList(0, i + 1)));
}
return path;
}
}
public QueryableHibernateList<T> setEntity(Class<T> type) { public QueryableHibernateList<T> setEntity(Class<T> type) {
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
this.query = builder.createQuery(type);
this.root = this.query.from(this.tClass);
return this; return this;
} }
@ -125,6 +144,7 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
return this.manager.createQuery(criteriaQuery).getSingleResult(); return this.manager.createQuery(criteriaQuery).getSingleResult();
} }
@Async
public CompletableFuture<Long> countAsync() { public CompletableFuture<Long> countAsync() {
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder(); CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class); CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class);
@ -169,10 +189,33 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
} }
public List<T> toList() { public List<T> toList() {
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
else this.query = builder.createQuery(this.tClass);
this.root = this.query.from(this.tClass);
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot)); this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root)); if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root));
if (this.fields != null && !this.fields.isEmpty()) this.selectFields(); if (!this.fields.isEmpty()) this.selectFields();
if (distinct) this.query.distinct(true); if (distinct) this.query.distinct(true);
if (!this.fields.isEmpty()) return this.toListWithFields();
else return this.toListWithOutFields();
}
private List<T> toListWithFields() {
List<Tuple> results = this.manager.createQuery(query).getResultList();
Map<Object, List<Tuple>> groupedResults = results.stream()
.collect(Collectors.groupingBy(x -> x.get("id")));
return results.stream().map(x -> {
try {
return (T) this.tClass.newInstance().buildFromTuple(groupedResults.get(x.get("id")), "");
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.toList());
}
private List<T> toListWithOutFields() {
TypedQuery<T> typedQuery = this.manager.createQuery(this.query); TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
if (this.offset != null) typedQuery.setFirstResult(this.offset); if (this.offset != null) typedQuery.setFirstResult(this.offset);
if (this.length != null) typedQuery.setMaxResults(this.length); if (this.length != null) typedQuery.setMaxResults(this.length);
@ -183,11 +226,35 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
return typedQuery.getResultList(); return typedQuery.getResultList();
} }
@Async
public CompletableFuture<List<T>> toListAsync() { public CompletableFuture<List<T>> toListAsync() {
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
else this.query = builder.createQuery(this.tClass);
this.root = this.query.from(this.tClass);
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot)); this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root)); if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root));
if (this.fields != null && !this.fields.isEmpty()) this.selectFields(); if (!this.fields.isEmpty()) this.selectFields();
if (distinct) this.query.distinct(true); if (distinct) this.query.distinct(true);
if (!this.fields.isEmpty()) return this.toListAsyncWithFields();
else return this.toListAsyncWithOutFields();
}
private CompletableFuture<List<T>> toListAsyncWithFields() {
List<Tuple> results = this.manager.createQuery(query).getResultList();
Map<Object, List<Tuple>> groupedResults = results.stream()
.collect(Collectors.groupingBy(x -> x.get("id")));
return CompletableFuture.supplyAsync(() -> results.stream().map(x -> {
try {
return (T) this.tClass.newInstance().buildFromTuple(groupedResults.get(x.get("id")), "");
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
return null;
}).collect(Collectors.toList()));
}
private CompletableFuture<List<T>> toListAsyncWithOutFields() {
TypedQuery<T> typedQuery = this.manager.createQuery(this.query); TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
if (this.offset != null) typedQuery.setFirstResult(this.offset); if (this.offset != null) typedQuery.setFirstResult(this.offset);
if (this.length != null) typedQuery.setMaxResults(this.length); if (this.length != null) typedQuery.setMaxResults(this.length);
@ -201,17 +268,26 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
} }
public T getSingle() { public T getSingle() {
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
else this.query = builder.createQuery(this.tClass);
this.root = this.query.from(this.tClass);
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot)); this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
if (this.fields != null && !this.fields.isEmpty()) this.selectFields(); if (!this.fields.isEmpty()) this.selectFields();
TypedQuery<T> typedQuery = this.manager.createQuery(this.query); TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
if (this.hint != null) if (this.hint != null)
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint)); typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
return typedQuery.getSingleResult(); return typedQuery.getSingleResult();
} }
@Async
public CompletableFuture<T> getSingleAsync() { public CompletableFuture<T> getSingleAsync() {
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
else this.query = builder.createQuery(this.tClass);
this.root = this.query.from(this.tClass);
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot)); this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
if (this.fields != null && !this.fields.isEmpty()) this.selectFields(); if (!this.fields.isEmpty()) this.selectFields();
TypedQuery<T> typedQuery = this.manager.createQuery(this.query); TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
if (this.hint != null) if (this.hint != null)
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint)); typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
@ -219,8 +295,12 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
} }
public T getSingleOrDefault() { public T getSingleOrDefault() {
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
else this.query = builder.createQuery(this.tClass);
this.root = this.query.from(this.tClass);
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot)); this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
if (this.fields != null && !this.fields.isEmpty()) this.selectFields(); if (!this.fields.isEmpty()) this.selectFields();
TypedQuery<T> typedQuery = this.manager.createQuery(this.query); TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
if (this.hint != null) if (this.hint != null)
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint)); typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
@ -230,9 +310,14 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
else throw new NotSingleResultException("Query returned more than one items"); else throw new NotSingleResultException("Query returned more than one items");
} }
@Async
public CompletableFuture<T> getSingleOrDefaultAsync() { public CompletableFuture<T> getSingleOrDefaultAsync() {
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
else this.query = builder.createQuery(this.tClass);
this.root = this.query.from(this.tClass);
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot)); this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
if (this.fields != null && !this.fields.isEmpty()) this.selectFields(); if (!this.fields.isEmpty()) this.selectFields();
TypedQuery<T> typedQuery = this.manager.createQuery(this.query); TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
if (this.hint != null) if (this.hint != null)
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint)); typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));

View File

@ -1,7 +1,10 @@
package eu.eudat.queryable.queryableentity; package eu.eudat.queryable.queryableentity;
import javax.persistence.Tuple;
import java.util.List;
public interface DataEntity<T,K> { public interface DataEntity<T,K> {
void update(T entity); void update(T entity);
K getKeys(); K getKeys();
T buildFromTuple(List<Tuple> tuple, String base);
} }

View File

@ -6,8 +6,10 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication @SpringBootApplication
@EnableAsync
public class EuDatApplication extends SpringBootServletInitializer { public class EuDatApplication extends SpringBootServletInitializer {
private static final Logger logger = LoggerFactory.getLogger(EuDatApplication.class); private static final Logger logger = LoggerFactory.getLogger(EuDatApplication.class);

View File

@ -2,10 +2,9 @@ package eu.eudat.configurations;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.ComponentScan; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.*;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.jdbc.datasource.DriverManagerDataSource;
@ -37,25 +36,26 @@ public class DevelDatabaseConfiguration {
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
em.setJpaVendorAdapter(vendorAdapter); em.setJpaVendorAdapter(vendorAdapter);
em.setJpaProperties(additionalProperties()); em.setJpaProperties(additionalProperties());
return em; return em;
} }
@Bean @Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() { public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource(); return DataSourceBuilder
dataSource.setDriverClassName(env.getProperty("database.driver-class-name")); .create()
dataSource.setUrl(env.getProperty("devel.database.url")); .username(env.getProperty("devel.database.username"))
dataSource.setUsername(env.getProperty("devel.database.username")); .password(env.getProperty("devel.database.password"))
dataSource.setPassword(env.getProperty("devel.database.password")); .url(env.getProperty("devel.database.url"))
return dataSource; .driverClassName(env.getProperty("database.driver-class-name"))
.build();
} }
@Bean @Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) { public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
JpaTransactionManager transactionManager = new JpaTransactionManager(); JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf); transactionManager.setEntityManagerFactory(emf);
return transactionManager; return transactionManager;
} }
@ -69,6 +69,10 @@ public class DevelDatabaseConfiguration {
properties.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQL92Dialect"); properties.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQL92Dialect");
properties.setProperty("hibernate.show_sql", "true"); properties.setProperty("hibernate.show_sql", "true");
properties.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false"); properties.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false");
properties.setProperty("hibernate.c3p0.maxPoolSize", "70");
properties.setProperty("hibernate.c3p0.timeout", "5000");
properties.setProperty("hibernate.connection.release_mode", "after_transaction");
//properties.setProperty("hibernate.connection.provider_class", "org.hibernate.c3p0.internal.C3P0ConnectionProvider");
return properties; return properties;
} }
} }

View File

@ -0,0 +1,28 @@
package eu.eudat.configurations;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by ikalyvas on 9/26/2018.
*/
@Configuration
public class ExecutorServiceConfig {
@Bean
public Executor asyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2);
executor.setMaxPoolSize(2);
executor.setQueueCapacity(500);
executor.setThreadNamePrefix("Rules-");
executor.initialize();
return executor;
}
}

View File

@ -1,11 +1,15 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.core.logger.Logger;
import eu.eudat.logic.managers.AdminManager; import eu.eudat.logic.managers.AdminManager;
import eu.eudat.logic.managers.UserManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.helpers.LoggerService;
import eu.eudat.models.data.admin.composite.DatasetProfile; import eu.eudat.models.data.admin.composite.DatasetProfile;
import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.security.Principal; import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.types.ApiMessageCode; import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -24,13 +28,14 @@ import static eu.eudat.types.Authorities.ADMIN;
public class Admin extends BaseController { public class Admin extends BaseController {
@Autowired @Autowired
public Admin(ApiContext apiContext) { public Admin(ApiContext apiContext, Logger logger) {
super(apiContext); super(apiContext);
} }
@Transactional @Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext()); eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition); this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId()); return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
@ -39,6 +44,7 @@ public class Admin extends BaseController {
@Transactional @Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp/{id}"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
//this.getLoggerService().info(principal, "Admin Edited Dataset Profile");
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext()); eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
@ -50,9 +56,20 @@ public class Admin extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/admin/get/{id}"}, produces = "application/json") @RequestMapping(method = RequestMethod.GET, value = {"/admin/get/{id}"}, produces = "application/json")
public ResponseEntity<ResponseItem<DatasetProfile>> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) { public ResponseEntity<ResponseItem<DatasetProfile>> get(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
//this.getLoggerService().info(principal, "Admin Open Dataset Profile");
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
datasetprofile.setLabel(profile.getLabel()); datasetprofile.setLabel(profile.getLabel());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(datasetprofile));
} }
@RequestMapping(method = RequestMethod.POST, value = {"/admin/preview"}, consumes = "application/json",produces = "application/json")
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
//this.getLoggerService().info(principal, "Admin Previewed Dataset Profile");
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = UserManager.generateDatasetProfileModel(modelDefinition);
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
}
} }

View File

@ -1,20 +1,30 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.core.logger.Logger;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.helpers.LoggerService;
import eu.eudat.models.validators.*; import eu.eudat.models.validators.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.InitBinder;
public abstract class BaseController { public abstract class BaseController {
private Logger logger;
private ApiContext apiContext; private ApiContext apiContext;
public ApiContext getApiContext() { public ApiContext getApiContext() {
return apiContext; return apiContext;
} }
public Logger getLoggerService() {
return logger;
}
public BaseController(ApiContext apiContext) { public BaseController(ApiContext apiContext) {
this.apiContext = apiContext; this.apiContext = apiContext;
} }

View File

@ -1,6 +1,7 @@
package eu.eudat.controllers; package eu.eudat.controllers;
import eu.eudat.data.entities.Dataset; import eu.eudat.data.entities.Dataset;
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest; import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.security.claims.ClaimedAuthorities;
@ -33,7 +34,14 @@ public class Datasets extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/datasets/getPaged"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/datasets/getPaged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception { ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) throws Exception {
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext(), datasetTableRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.POST, value = {"/datasets/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPublicPaged(@RequestBody DatasetPublicTableRequest datasetTableRequest, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext(), datasetTableRequest, principal); DataTableData<DatasetListingModel> dataTable = new DatasetManager().getPaged(this.getApiContext(), datasetTableRequest, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
} }

View File

@ -6,6 +6,7 @@ import eu.eudat.data.query.items.table.project.ProjectTableRequest;
import eu.eudat.logic.managers.ProjectManager; import eu.eudat.logic.managers.ProjectManager;
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet; import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
import eu.eudat.logic.proxy.config.exceptions.NoURLFound; import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.ApiContext;
import eu.eudat.models.data.external.ProjectsExternalSourcesModel; import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.common.DataTableData;
@ -25,6 +26,9 @@ import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static eu.eudat.types.Authorities.ADMIN;
import static eu.eudat.types.Authorities.ANONYMOUS;
@RestController @RestController
@CrossOrigin @CrossOrigin
@ -78,7 +82,7 @@ public class Projects extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/projects/get"}, consumes = "application/json", produces = "application/json") @RequestMapping(method = RequestMethod.POST, value = {"/projects/get"}, consumes = "application/json", produces = "application/json")
public @ResponseBody public @ResponseBody
ResponseEntity<ResponseItem<List<eu.eudat.models.data.project.Project>>> get(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException { ResponseEntity<ResponseItem<List<eu.eudat.models.data.project.Project>>> get(@RequestBody ProjectCriteriaRequest projectCriteria, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
List<eu.eudat.models.data.project.Project> dataTable = new ProjectManager().getCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher()); List<eu.eudat.models.data.project.Project> dataTable = new ProjectManager().getCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE)); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
} }

View File

@ -1,21 +1,19 @@
package eu.eudat.logic.handlers; package eu.eudat.logic.handlers;
import eu.eudat.exceptions.security.UnauthorisedException; import eu.eudat.exceptions.security.UnauthorisedException;
import eu.eudat.models.data.security.Principal;
import eu.eudat.logic.security.claims.ClaimedAuthorities; import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.operations.AuthenticationService; import eu.eudat.logic.services.operations.AuthenticationService;
import eu.eudat.models.data.security.Principal;
import eu.eudat.types.Authorities; import eu.eudat.types.Authorities;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.support.WebDataBinderFactory; import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest; import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer; import org.springframework.web.method.support.ModelAndViewContainer;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
public final class PrincipalArgumentResolver implements HandlerMethodArgumentResolver { public final class PrincipalArgumentResolver implements HandlerMethodArgumentResolver {
@ -32,7 +30,8 @@ public final class PrincipalArgumentResolver implements HandlerMethodArgumentRes
String token = nativeWebRequest.getHeader("AuthToken"); String token = nativeWebRequest.getHeader("AuthToken");
Optional<Annotation> claimsAnnotation = Arrays.stream(methodParameter.getParameterAnnotations()).filter(annotation -> annotation.annotationType().equals(ClaimedAuthorities.class)).findAny(); Optional<Annotation> claimsAnnotation = Arrays.stream(methodParameter.getParameterAnnotations()).filter(annotation -> annotation.annotationType().equals(ClaimedAuthorities.class)).findAny();
List<Authorities> claimList = claimsAnnotation.map(annotation -> Arrays.asList(((ClaimedAuthorities) annotation).claims())).orElse(Authorities.all()); List<Authorities> claimList = claimsAnnotation.map(annotation -> Arrays.asList(((ClaimedAuthorities) annotation).claims())).orElse(Authorities.all());
if(token == null && claimList.size() == 1 && claimList.get(0).equals(Authorities.ANONYMOUS)) return new Principal(); if (token == null && claimList.size() == 1 && claimList.get(0).equals(Authorities.ANONYMOUS))
return new Principal();
if (token == null) throw new UnauthorisedException("Authentication Information Is Missing"); if (token == null) throw new UnauthorisedException("Authentication Information Is Missing");
UUID authToken; UUID authToken;
try { try {
@ -45,6 +44,13 @@ public final class PrincipalArgumentResolver implements HandlerMethodArgumentRes
if (principal == null) throw new UnauthorisedException("Authentication Information Missing"); if (principal == null) throw new UnauthorisedException("Authentication Information Missing");
if (!claimList.contains(Authorities.ANONYMOUS) && !principal.isAuthorized(claimList)) if (!claimList.contains(Authorities.ANONYMOUS) && !principal.isAuthorized(claimList))
throw new UnauthorisedException("You are not Authorized For this Action"); throw new UnauthorisedException("You are not Authorized For this Action");
/*Principal principal1 = new Principal();
principal1.setId(UUID.fromString("46366b8a-a712-4e0c-a499-1a3a0f209325"));
principal1.setToken(UUID.fromString("19031e80-6534-4aa5-b68a-78e97042c968"));
principal1.setName("Ioannis Kalyvas");
principal1.setAvatarUrl("https://lh5.googleusercontent.com/-X65vX1QO_Ew/AAAAAAAAAAI/AAAAAAAAAAA/AAN31DU5lFIOwD_fZiYW96D410pn6v4E-Q/s96-c/photo.jpg");
principal1.setAuthorities(new HashSet<>(Arrays.asList(Authorities.ADMIN, Authorities.USER)));
principal1.setExpiresAt(addADay(new Date()));*/
return principal; return principal;
} }
@ -52,4 +58,13 @@ public final class PrincipalArgumentResolver implements HandlerMethodArgumentRes
this.authenticationService = authenticationService; this.authenticationService = authenticationService;
} }
private Date addADay(Date date) {
Date dt = new Date();
Calendar c = Calendar.getInstance();
c.setTime(dt);
c.add(Calendar.DATE, 1);
dt = c.getTime();
return dt;
}
} }

View File

@ -235,7 +235,7 @@ public class DataManagementPlanManager {
} }
} }
@Async
private static void copyDatasets(DMP newDmp, DatasetDao datasetDao) { private static void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
List<CompletableFuture<Dataset>> futures = new LinkedList<>(); List<CompletableFuture<Dataset>> futures = new LinkedList<>();
for (Dataset dataset : newDmp.getDataset()) { for (Dataset dataset : newDmp.getDataset()) {

View File

@ -6,6 +6,7 @@ import eu.eudat.data.dao.criteria.RegistryCriteria;
import eu.eudat.data.dao.criteria.ServiceCriteria; import eu.eudat.data.dao.criteria.ServiceCriteria;
import eu.eudat.data.dao.entities.*; import eu.eudat.data.dao.entities.*;
import eu.eudat.data.entities.*; import eu.eudat.data.entities.*;
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest; import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
import eu.eudat.elastic.criteria.DatasetCriteria; import eu.eudat.elastic.criteria.DatasetCriteria;
import eu.eudat.elastic.repository.DatasetRepository; import eu.eudat.elastic.repository.DatasetRepository;
@ -76,6 +77,25 @@ public class DatasetManager {
return dataTable; return dataTable;
} }
public DataTableData<DatasetListingModel> getPaged(ApiContext apiContext, DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception {
datasetTableRequest.setQuery(apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
QueryableList<eu.eudat.data.entities.Dataset> pagedItems = PaginationManager.applyPaging(datasetTableRequest.applyCriteria(), datasetTableRequest);
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
CompletableFuture<List<DatasetListingModel>> itemsFuture = pagedItems.
selectAsync(item -> new DatasetListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> {
dataTable.setData(resultList);
});
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> {
dataTable.setTotalCount(count);
});
CompletableFuture.allOf(itemsFuture, countFuture).join();
return dataTable;
}
public DatasetWizardModel getSingle(DatasetDao datatasetRepository, DatasetRepository elasticDatasetRepository, String id) throws InstantiationException, IllegalAccessException, IOException { public DatasetWizardModel getSingle(DatasetDao datatasetRepository, DatasetRepository elasticDatasetRepository, String id) throws InstantiationException, IllegalAccessException, IOException {
DatasetWizardModel dataset = new DatasetWizardModel(); DatasetWizardModel dataset = new DatasetWizardModel();
eu.eudat.data.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class)); eu.eudat.data.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));

View File

@ -97,6 +97,7 @@ public class ProjectManager {
public List<eu.eudat.models.data.project.Project> getCriteria(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound { public List<eu.eudat.models.data.project.Project> getCriteria(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectCriteria.getCriteria()); QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectCriteria.getCriteria());
if(projectCriteria.getLength() != null) items.take(projectCriteria.getLength());
List<eu.eudat.models.data.project.Project> projects = items.select(item -> new Project().fromDataModel(item)); List<eu.eudat.models.data.project.Project> projects = items.select(item -> new Project().fromDataModel(item));
return projects; return projects;
} }

View File

@ -6,6 +6,7 @@ import eu.eudat.models.data.dmp.Organisation;
import eu.eudat.logic.utilities.helpers.LabelBuilder; import eu.eudat.logic.utilities.helpers.LabelBuilder;
import eu.eudat.models.data.urls.DatasetUrlListing; import eu.eudat.models.data.urls.DatasetUrlListing;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -16,9 +17,9 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
private String label; private String label;
private String project; private String project;
private String profile; private String profile;
private String creationTime; private Date creationTime;
private String organisations; private String organisations;
private String version; private int version;
private UUID groupId; private UUID groupId;
private List<DatasetUrlListing> datasets; private List<DatasetUrlListing> datasets;
@ -54,11 +55,11 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
this.profile = profile; this.profile = profile;
} }
public String getCreationTime() { public Date getCreationTime() {
return creationTime; return creationTime;
} }
public void setCreationTime(String creationTime) { public void setCreationTime(Date creationTime) {
this.creationTime = creationTime; this.creationTime = creationTime;
} }
@ -70,11 +71,11 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
this.organisations = organisations; this.organisations = organisations;
} }
public String getVersion() { public int getVersion() {
return version; return version;
} }
public void setVersion(String version) { public void setVersion(int version) {
this.version = version; this.version = version;
} }
@ -101,8 +102,8 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
this.project = entity.getProject().getLabel(); this.project = entity.getProject().getLabel();
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel(); if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList())); this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
this.creationTime = entity.getCreated().toString(); this.creationTime = entity.getCreated();
this.version = "" + entity.getVersion(); this.version = entity.getVersion();
this.groupId = entity.getGroupId(); this.groupId = entity.getGroupId();
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList()); this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
return this; return this;

View File

@ -6,6 +6,7 @@ import eu.eudat.models.data.dataset.DataRepository;
import eu.eudat.models.data.dataset.Service; import eu.eudat.models.data.dataset.Service;
import eu.eudat.logic.utilities.helpers.LabelBuilder; import eu.eudat.logic.utilities.helpers.LabelBuilder;
import java.util.Date;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -17,8 +18,8 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
private String dataRepositories; private String dataRepositories;
private String registries; private String registries;
private String services; private String services;
private String status; private int status;
private String created; private Date created;
private String description; private String description;
public String getId() { public String getId() {
@ -77,19 +78,19 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
this.services = services; this.services = services;
} }
public String getStatus() { public int getStatus() {
return status; return status;
} }
public void setStatus(String status) { public void setStatus(int status) {
this.status = status; this.status = status;
} }
public String getCreated() { public Date getCreated() {
return created; return created;
} }
public void setCreated(String created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
@ -105,11 +106,11 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
public DatasetListingModel fromDataModel(Dataset entity) { public DatasetListingModel fromDataModel(Dataset entity) {
this.id = entity.getId().toString(); this.id = entity.getId().toString();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.created = entity.getCreated().toString(); this.created = entity.getCreated();
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : ""; this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
this.profile = entity.getProfile() != null ? entity.getProfile().getLabel() : ""; this.profile = entity.getProfile() != null ? entity.getProfile().getLabel() : "";
this.description = entity.getDescription(); this.description = entity.getDescription();
this.status = "" + entity.getStatus(); this.status = entity.getStatus();
this.registries = LabelBuilder.getLabel(entity.getRegistries().stream().map(item -> new eu.eudat.models.data.dataset.Registry().fromDataModel(item)).collect(Collectors.toList())); this.registries = LabelBuilder.getLabel(entity.getRegistries().stream().map(item -> new eu.eudat.models.data.dataset.Registry().fromDataModel(item)).collect(Collectors.toList()));
this.dataRepositories = LabelBuilder.getLabel(entity.getDatasetDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item.getDataRepository())).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())); this.services = LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()));

View File

@ -7,6 +7,7 @@ import eu.eudat.models.data.files.ContentFile;
import eu.eudat.models.data.urls.DataManagementPlanUrlListing; import eu.eudat.models.data.urls.DataManagementPlanUrlListing;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -26,17 +27,17 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
private String definition; private String definition;
private String startDate; private Date startDate;
private String endDate; private Date endDate;
private Project.Status status; private Project.Status status;
private UserInfo creationUser; private UserInfo creationUser;
private String created; private Date created;
private String modified; private Date modified;
private String description; private String description;
@ -117,35 +118,39 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
this.creationUser = creationUser; this.creationUser = creationUser;
} }
public String getStartDate() { public Date getStartDate() {
return startDate; return startDate;
} }
public void setStartDate(String startDate) { public void setStartDate(Date startDate) {
this.startDate = startDate; this.startDate = startDate;
} }
public String getEndDate() { public Date getEndDate() {
return endDate; return endDate;
} }
public void setEndDate(String endDate) { public void setEndDate(Date endDate) {
this.endDate = endDate; this.endDate = endDate;
} }
public String getCreated() { public void setStatus(Project.Status status) {
this.status = status;
}
public Date getCreated() {
return created; return created;
} }
public void setCreated(String created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
public String getModified() { public Date getModified() {
return modified; return modified;
} }
public void setModified(String modified) { public void setModified(Date modified) {
this.modified = modified; this.modified = modified;
} }
@ -173,11 +178,11 @@ public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Pro
this.reference = entity.getReference(); this.reference = entity.getReference();
this.uri = entity.getUri(); this.uri = entity.getUri();
this.definition = entity.getDefinition(); this.definition = entity.getDefinition();
this.startDate = entity.getStartdate() != null ? entity.getStartdate().toString() : null; this.startDate = entity.getStartdate();
this.endDate = entity.getEnddate() != null ? entity.getEnddate().toString() : null; this.endDate = entity.getEnddate();
this.setStatus(entity.getStatus()); this.setStatus(entity.getStatus());
this.created = entity.getCreated().toString(); this.created = entity.getCreated();
this.modified = entity.getModified().toString(); this.modified = entity.getModified();
this.description = entity.getDescription(); this.description = entity.getDescription();
this.dmps = entity.getDmps().stream().map(item -> new DataManagementPlanUrlListing().fromDataModel(item)).collect(Collectors.toList()); this.dmps = entity.getDmps().stream().map(item -> new DataManagementPlanUrlListing().fromDataModel(item)).collect(Collectors.toList());
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null)); this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));

View File

@ -3,12 +3,13 @@
#eu.eudat.logic.security.portmapping.https = 7444 #eu.eudat.logic.security.portmapping.https = 7444
########################/Security######################################## ########################/Security########################################
server.port=8080 server.port=8080
server.tomcat.max-threads = 1000
logging.file=/logs/spring-boot-logging.log logging.file=/logs/spring-boot-logging.log
##########################Persistence########################################## ##########################Persistence##########################################
database.driver-class-name=org.postgresql.Driver database.driver-class-name=org.postgresql.Driver
devel.database.url=jdbc:postgresql://dbserver02.local.cite.gr:5432/dmptool devel.database.url=jdbc:postgresql://localhost:32768/dmptool
devel.database.username=dmtadm devel.database.username=postgres
devel.database.password=t00L4DM@18! devel.database.password=
production.database.url=jdbc:postgresql://develdb1.madgik.di.uoa.gr:5432/dmptool production.database.url=jdbc:postgresql://develdb1.madgik.di.uoa.gr:5432/dmptool
production.database.username=dmptool production.database.username=dmptool
production.database.password=dmpt00lu$r production.database.password=dmpt00lu$r
@ -69,7 +70,19 @@ project.configuration.grant.name = Grant
################################################################################# #################################################################################
http-logger.initial-delay = 0 http-logger.initial-delay = 0
http-logger.delay = 10 http-logger.delay = 10
http-logger.server-address = http://logstash:31311 http-logger.server-address = http://localhost:31311
#############################Elastic Search###################################### #############################Elastic Search######################################
elasticsearch.host = elasticsearch-dmp elasticsearch.host = localhost
elasticsearch.port = 9200 elasticsearch.port = 9201
############################
# Number of ms to wait before throwing an exception if no connection is available.
spring.datasource.maxIdle: 10
spring.datasource.max-active: 70
spring.datasource.max-wait: 10000
spring.datasource.validationQuery: select 1
spring.datasource.removeAbandoned: true
spring.datasource.removeAbandonedTimeout: 1
spring.datasource.logAbandoned: true
spring.datasource.testOnBorrow: true
spring.datasource.testOnConnect: false
spring.datasource.testWhileIdle: false

View File

@ -12,4 +12,5 @@ RUN if [ "$env" = "prod" ]; then ng build --$env --$aot; else ng build --$aot;
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx # Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.13 FROM nginx:1.13
COPY --from=angular /app/dist/ /usr/share/nginx/html COPY --from=angular /app/dist/ /usr/share/nginx/html
COPY --from=angular /app/static/ /usr/share/nginx/static
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf

View File

@ -5,4 +5,8 @@ server {
index index.html index.htm; index index.html index.htm;
try_files $uri $uri/ /index.html =404; try_files $uri $uri/ /index.html =404;
} }
location /material/ {
alias /usr/share/nginx/static/;
}
} }

View File

@ -35,6 +35,7 @@ import { BreadCrumbResolverService } from './services/breadcrumb/breadcrumb-reso
import { MAT_DATE_LOCALE } from '@angular/material'; import { MAT_DATE_LOCALE } from '@angular/material';
import { CultureService } from './utilities/culture/culture-service'; import { CultureService } from './utilities/culture/culture-service';
@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,

View File

@ -1,70 +1,77 @@
<div> <div>
<h4 style="font-weight: bold">Composite Field Description</h4>
<div fxLayout="row">
<mat-checkbox [(ngModel)]="isComposite" (ngModelChange)="onIsCompositeChange(isComposite)">Composite Field</mat-checkbox> <mat-checkbox [(ngModel)]="isComposite" (ngModelChange)="onIsCompositeChange(isComposite)">Composite Field</mat-checkbox>
<mat-checkbox [(ngModel)]="isMultiplicityEnabled" (ngModelChange)="onIsMultiplicityEnabledChange(isMultiplicityEnabled)">Multiplicity</mat-checkbox> <mat-checkbox [(ngModel)]="isMultiplicityEnabled" (ngModelChange)="onIsMultiplicityEnabledChange(isMultiplicityEnabled)">Multiplicity</mat-checkbox>
<div [formGroup]="form"> <mat-checkbox [formControl]="this.form.get('hasCommentField')"> Comment</mat-checkbox>
<mat-checkbox formControlName="hasCommentField"> Comment</mat-checkbox> </div>
<div class="row"> <div fxLayout="row">
<div class="form-group col-md-6"> <div fxFlex>
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput type="text" placeholder="Title" formControlName="title"> <input matInput type="text" placeholder="Title" [formControl]="this.form.get('title')">
</mat-form-field> </mat-form-field>
<mat-form-field class="full-width">
<input matInput type="text" placeholder="Description" formControlName="description">
</mat-form-field>
<mat-form-field class="full-width">
<input matInput type="text" placeholder="Extended Description" formControlName="extendedDescription">
</mat-form-field>
</div>
<div class="form-group col-md-6">
<div *ngIf="isMultiplicityEnabled" class="col-md-6" formGroupName="multiplicity">
<div>
<mat-form-field class="full-width">
<input matInput placeholder="Min" type="number" formControlName="min">
</mat-form-field>
<mat-form-field class="full-width">
<input matInput placeholder="Max" type="number" formControlName="max">
</mat-form-field>
</div>
</div>
<mat-form-field class="full-width">
<input matInput type="number" placeholder="Ordinal" formControlName="ordinal">
</mat-form-field>
<div *ngIf="isComposite" class="col-md-6">
<mat-form-field class="full-width">
<input matInput type="string" placeholder="Id" formControlName="id">
</mat-form-field>
</div>
</div>
</div>
</div> </div>
<div fxFlex>
<field-form *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" [dataModel]="dataModel.fields[0]" [showMultiplicity]="false" <mat-form-field class="full-width">
[indexPath]="indexPath + 'f' + 0"></field-form> <input matInput type="text" placeholder="Description" [formControl]="this.form.get('description')">
</mat-form-field>
<div *ngIf="isComposite">
<mat-expansion-panel *ngFor="let field of dataModel.fields let i=index;">
<mat-expansion-panel-header>
<mat-panel-title *ngIf="form.get('fields').get(''+i).get('title').value">{{i + 1}}. {{form.get('fields').get(''+i).get('title').value}}</mat-panel-title>
<div class="btn-group pull-right">
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteField(i);">
<span class="glyphicon glyphicon-erase"></span>
</button>
</div>
</mat-expansion-panel-header>
<div id="{{indexPath + 'f' + i}}">
<field-form [form]="form.get('fields').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'f' + i"></field-form>
</div>
</mat-expansion-panel>
</div> </div>
<div fxFlex>
<div *ngIf="isComposite"> <mat-form-field class="full-width">
<a (click)="addNewField()" style="cursor: pointer"> <input matInput type="text" placeholder="Extended Description" [formControl]="this.form.get('extendedDescription')">
Add Child Field + </mat-form-field>
</a>
</div> </div>
</div>
<div fxLayout="row">
</div> <div fxFlex *ngIf="isMultiplicityEnabled">
<mat-form-field class="full-width">
<input matInput placeholder="Min" type="number" [formControl]="this.form.get('multiplicity').get('min')">
</mat-form-field>
</div>
<div fxFlex *ngIf="isMultiplicityEnabled">
<mat-form-field class="full-width">
<input matInput placeholder="Max" type="number" [formControl]="this.form.get('multiplicity').get('max')">
</mat-form-field>
</div>
<div fxFlex>
<mat-form-field class="full-width">
<input matInput type="number" placeholder="Ordinal" [formControl]="this.form.get('ordinal')">
</mat-form-field>
</div>
<div fxFlex *ngIf="isComposite">
<mat-form-field class="full-width">
<input matInput type="string" placeholder="Id" [formControl]="this.form.get('id')">
</mat-form-field>
</div>
</div>
</div>
<div fxLayout="row">
<h4 style="font-weight: bold">Field Description</h4>
<div *ngIf="isComposite">
<button mat-button (click)="addNewField()" style="cursor: pointer">
Add Child Field +
</button>
</div>
</div>
<field-form *ngIf="!isComposite" [form]="form.get('fields').get(''+0)" [dataModel]="dataModel.fields[0]" [showMultiplicity]="false"
[indexPath]="indexPath + 'f' + 0"></field-form>
<div *ngIf="isComposite">
<mat-expansion-panel *ngFor="let field of dataModel.fields let i=index;" #panel>
<mat-expansion-panel-header>
<mat-panel-title *ngIf="form.get('fields').get(''+i).get('title').value && !panel.expanded">{{i + 1}}. {{form.get('fields').get(''+i).get('title').value}}</mat-panel-title>
<div class="btn-group pull-right">
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteField(i);">
<span class="glyphicon glyphicon-erase"></span>
</button>
</div>
</mat-expansion-panel-header>
<div id="{{indexPath + 'f' + i}}" *ngIf="panel.expanded">
<field-form [form]="form.get('fields').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'f' + i"></field-form>
</div>
</mat-expansion-panel>
</div>

View File

@ -1,8 +1,8 @@
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { FieldSet } from 'app/models/datasetProfileAdmin/FieldSet';
import { Field } from 'app/models/datasetProfileAdmin/Field';
import { FormArray, FormControl } from '@angular/forms'; import { FormArray, FormControl } from '@angular/forms';
import { FieldSet } from '../../models/datasetProfileAdmin/FieldSet';
import { Field } from '../../models/datasetProfileAdmin/Field';
@Component({ @Component({
selector: 'compositefield-form', selector: 'compositefield-form',
@ -54,4 +54,4 @@ export class CompositeFieldFormComponent {
this.dataModel.fields.splice(index, 1); this.dataModel.fields.splice(index, 1);
(<FormArray>this.form.get("fields")).removeAt(index); (<FormArray>this.form.get("fields")).removeAt(index);
} }
} }

View File

@ -24,56 +24,63 @@ import { WordlistComponent } from '../shared/componentsAdmin/wordlist/wordlist-c
import { AutocompleteComponent } from '../shared/componentsAdmin/autocomplete/autocomplete-component'; import { AutocompleteComponent } from '../shared/componentsAdmin/autocomplete/autocomplete-component';
import { ComboboxComponent } from '../shared/componentsAdmin/combobox/combobox-component'; import { ComboboxComponent } from '../shared/componentsAdmin/combobox/combobox-component';
import { SharedModule } from "../shared/shared.module"; import { SharedModule } from "../shared/shared.module";
import { DatasetProfilePreviewerComponent } from "./previewer/dataset-profile-previewer.component";
import { DynamicFormModule } from "../form/dynamic-form.module";
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
FormsModule, FormsModule,
HttpClientModule, HttpClientModule,
ReactiveFormsModule, ReactiveFormsModule,
RouterModule, RouterModule,
SharedModule, SharedModule,
RouterModule.forChild(DatasetProfileRoutes) DynamicFormModule,
], RouterModule.forChild(DatasetProfileRoutes)
],
declarations: [ declarations: [
FormComponent, FormComponent,
//GroupFieldFormComponent, //GroupFieldFormComponent,
RuleFormComponent, RuleFormComponent,
SectionFormComponent, SectionFormComponent,
PageFormComponent, PageFormComponent,
CompositeFieldFormComponent, CompositeFieldFormComponent,
FieldFormComponent, FieldFormComponent,
TextAreaComponent, TextAreaComponent,
CheckBoxComponent, CheckBoxComponent,
BooleanDecisionComponent, BooleanDecisionComponent,
FreeTextComponent, FreeTextComponent,
ComboboxComponent, ComboboxComponent,
AutocompleteComponent, AutocompleteComponent,
WordlistComponent, WordlistComponent,
RadioBoxComponent RadioBoxComponent,
], DatasetProfilePreviewerComponent
],
exports: [ exports: [
FormComponent, FormComponent,
//GroupFieldFormComponent, //GroupFieldFormComponent,
RuleFormComponent, RuleFormComponent,
SectionFormComponent, SectionFormComponent,
PageFormComponent, PageFormComponent,
CompositeFieldFormComponent, CompositeFieldFormComponent,
FieldFormComponent, FieldFormComponent,
TextAreaComponent, TextAreaComponent,
CheckBoxComponent, CheckBoxComponent,
BooleanDecisionComponent, BooleanDecisionComponent,
FreeTextComponent, FreeTextComponent,
ComboboxComponent, ComboboxComponent,
AutocompleteComponent, AutocompleteComponent,
WordlistComponent, WordlistComponent,
RadioBoxComponent RadioBoxComponent
], ],
providers: [ providers: [
] ],
entryComponents: [
DatasetProfilePreviewerComponent
]
}) })
export class DatasetProfileModule { } export class DatasetProfileModule { }

View File

@ -1,45 +1,24 @@
<div> <div>
<div [formGroup]="form"> <div fxLayout="row" fxLayoutAlign="start center">
<div class="row"> <div fxFlex>
<mat-form-field> <mat-form-field class="full-width">
<input matInput placeholder='Id' type="text" formControlName="id"> <input matInput placeholder='Id' type="text" [formControl]="this.form.get('id')">
</mat-form-field> </mat-form-field>
<div> <div fxFlex>
<div formGroupName="viewStyle"> <mat-form-field class="full-width">
<mat-form-field> <mat-select placeholder="View Style" [formControl]="this.form.get('viewStyle').get('renderStyle')" (change)="onchangeCombo()">
<mat-select placeholder="View Style" formControlName="renderStyle" (change)="onchangeCombo()"> <mat-option value="textarea">textarea</mat-option>
<mat-option value="textarea">textarea</mat-option> <mat-option value="booleanDecision">booleanDecision</mat-option>
<mat-option value="booleanDecision">booleanDecision</mat-option> <mat-option value='combobox'>combobox</mat-option>
<mat-option value='combobox'>combobox</mat-option> <mat-option value="checkBox">checkBox</mat-option>
<mat-option value="checkBox">checkBox</mat-option> <mat-option value="freetext">freetext</mat-option>
<mat-option value="freetext">freetext</mat-option> <mat-option value="radiobox">radiobox</mat-option>
<mat-option value="radiobox">radiobox</mat-option> </mat-select>
</mat-select> </mat-form-field>
</mat-form-field>
</div>
</div> </div>
</div> </div>
<div class="form" [ngSwitch]="form.get('viewStyle').get('renderStyle').value"> </div>
<div *ngSwitchCase="'combobox'"> <!-- <div class="row">
<combobox-component [form]="form" [dataModel]="dataModel"></combobox-component>
</div>
<div *ngSwitchCase="'radiobox'">
<radiobox-component [form]="form" [dataModel]="dataModel"></radiobox-component>
</div>
<div *ngSwitchCase="'freetext'">
<freetext-component [form]="form" [dataModel]="dataModel"></freetext-component>
</div>
<div *ngSwitchCase="'textarea'">
<textarea-component [form]="form" [dataModel]="dataModel"></textarea-component>
</div>
<div *ngSwitchCase="'booleanDecision'">
<booleanDecision-component [form]="form" [dataModel]="dataModel"></booleanDecision-component>
</div>
<div *ngSwitchCase="'checkBox'">
<checkbox-component [form]="form" [dataModel]="dataModel"></checkbox-component>
</div>
</div>
<!-- <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label>description</label> <label>description</label>
<input type="text" class="form-control" formControlName="description"> <input type="text" class="form-control" formControlName="description">
@ -49,43 +28,68 @@
<input type="text" class="form-control" formControlName="extendedDescription"> <input type="text" class="form-control" formControlName="extendedDescription">
</div> </div>
</div> --> </div> -->
<div class="row"> <div fxLayout="row" fxLayoutAlign="start center">
<div *ngIf="isFieldMultiplicityEnabled" formGroupName="multiplicity"> <div fxFlex *ngIf="isFieldMultiplicityEnabled">
<div> <h5>Multiplicity</h5>
<h5>Multiplicity</h5>
<mat-form-field class="full-width">
<input matInput type="number" placeholder="Min" formControlName="min">
</mat-form-field>
<mat-form-field class="full-width">
<input matInput type="number" placeholder="Max" formControlName="max">
</mat-form-field>
</div>
</div>
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput type="number" placeholder="Ordinal" formControlName="ordinal"> <input matInput type="number" placeholder="Min" [formControl]="this.form.get('multiplicity').get('min')">
</mat-form-field> </mat-form-field>
<div formGroupName="defaultValue">
<mat-form-field class="full-width">
<input matInput type="text" placeholder="Default Value" formControlName="value">
</mat-form-field>
</div>
<div class="col-md-5">
<div formArrayName="validations">
<div *ngFor="let validation of form['controls']['validations']['controls']; let i=index">
<mat-form-field>
<mat-select placeholder='Validation' [formControlName]="i">
<mat-option *ngFor="let option of validationsOptions" [value]="option.key">{{option.value}}</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
<mat-form-field class="full-width">
<input matInput type="number" placeholder="Max" [formControl]="this.form.get('multiplicity').get('max')">
</mat-form-field>
</div>
<div fxFlex>
<mat-form-field class="full-width">
<input matInput type="number" placeholder="Ordinal" [formControl]="this.form.get('ordinal')">
</mat-form-field>
</div>
<div fxFlex>
<mat-form-field class="full-width">
<input matInput type="text" placeholder="Default Value" [formControl]="this.form.get('defaultValue').get('value')">
</mat-form-field>
</div>
<div fxFlex>
<div>
<div *ngFor="let validation of form['controls']['validations']['controls']; let i=index">
<mat-form-field class="full-width">
<mat-select placeholder='Validation' [formControl]="this.form.get('validations').get(''+i)">
<mat-option *ngFor="let option of validationsOptions" [value]="option.key">{{option.value}}</mat-option>
</mat-select>
</mat-form-field>
</div>
</div> </div>
</div> </div>
</div> </div>
<div fxLayout="row" fxLayoutAlign="start center" [ngSwitch]="form.get('viewStyle').get('renderStyle').value">
<div class="full-width" *ngSwitchCase="'combobox'">
<combobox-component [form]="form" [dataModel]="dataModel"></combobox-component>
</div>
<div class="full-width" *ngSwitchCase="'radiobox'">
<radiobox-component [form]="form" [dataModel]="dataModel"></radiobox-component>
</div>
<div class="full-width" *ngSwitchCase="'freetext'">
<freetext-component [form]="form" [dataModel]="dataModel"></freetext-component>
</div>
<div class="full-width" *ngSwitchCase="'textarea'">
<textarea-component [form]="form" [dataModel]="dataModel"></textarea-component>
</div>
<div class="full-width" *ngSwitchCase="'booleanDecision'">
<booleanDecision-component [form]="form" [dataModel]="dataModel"></booleanDecision-component>
</div>
<div class="full-width" *ngSwitchCase="'checkBox'">
<checkbox-component [form]="form" [dataModel]="dataModel"></checkbox-component>
</div>
</div>
<mat-checkbox *ngIf="showMultiplicity" [(ngModel)]="isFieldMultiplicityEnabled" (ngModelChange)="onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled)">Multiplicity</mat-checkbox> <mat-checkbox *ngIf="showMultiplicity" [(ngModel)]="isFieldMultiplicityEnabled" (ngModelChange)="onIsFieldMultiplicityEnabledChange(isFieldMultiplicityEnabled)">Multiplicity</mat-checkbox>
<mat-expansion-panel *ngFor="let rule of dataModel.visible.rules let i=index;"> <div fxLayout="row">
<h4 style="font-weight: bold">Rules Description</h4>
<button mat-button (click)="addNewRule()" style="cursor: pointer">
Add Rule +
</button>
</div>
<mat-expansion-panel *ngFor="let rule of dataModel.visible.rules let i=index;" #panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title>{{i + 1}}. Rule {{i + 1}}</mat-panel-title> <mat-panel-title>{{i + 1}}. Rule {{i + 1}}</mat-panel-title>
@ -95,11 +99,9 @@
</button> </button>
</div> </div>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<rule-form [form]="form.get('visible').get('rules').get(''+i)" [dataModel]="rule"></rule-form> <rule-form *ngIf="panel.expanded" [form]="form.get('visible').get('rules').get(''+i)" [dataModel]="rule"></rule-form>
</mat-expansion-panel> </mat-expansion-panel>
<a (click)="addNewRule()" style="cursor: pointer">
Add Rule +
</a>
</div> </div>

View File

@ -1,63 +1,77 @@
<div class="container"> <div class="container">
<mat-card> <!-- <mat-card>
<form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> <form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
<div class="row"> <div class="row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput formControlName="label" placeholder="Label"> <input matInput formControlName="label" placeholder="Label">
</mat-form-field> </mat-form-field>
</div> </div>
</div> </div>
<button mat-raised-button color="primary" type="submit" [disabled]="!form.valid">Save</button>
</form>
</mat-card> -->
<mat-horizontal-stepper [linear]="true" #stepper>
<mat-step>
<div class="panel-group">
<mat-expansion-panel *ngFor="let page of dataModel.pages; let i=index;" #panel>
<mat-expansion-panel-header>
<mat-panel-title *ngIf="form.get('pages').at(i).get('title').value && !panel.expanded">{{i + 1}}.{{form.get('pages').at(i).get('title').value}}</mat-panel-title>
<div class="btn-group pull-right">
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeletePage(i);">
<span class="glyphicon glyphicon-erase"></span>
</button>
</div>
</mat-expansion-panel-header>
<div id="{{'p' + i}}" *ngIf="panel.expanded">
<div> <div>
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;"> <page-form [form]="form.get('pages').at(i)" [dataModel]="page"></page-form>
<mat-expansion-panel-header>
<mat-panel-title *ngIf="form.get('sections').get(''+i).get('title').value">{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title>
<div class="btn-group pull-right">
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteSection(i);">
<span class="glyphicon glyphicon-erase"></span>
</button>
</div>
</mat-expansion-panel-header>
<div id="{{'s' + i}}">
<div>
<section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="'s' + i"></section-form>
</div>
</div>
</mat-expansion-panel>
</div> </div>
</div>
</mat-expansion-panel>
</div>
<div class="panel-group"> <div style="margin-top:20px; padding-left: 15px;" class="row">
<mat-expansion-panel *ngFor="let page of dataModel.pages; let i=index;"> <button mat-button (click)="addPage()" style="cursor: pointer">
<mat-expansion-panel-header> Add Page +
<mat-panel-title *ngIf="form.get('pages').at(i).get('title').value">{{i + 1}}.{{form.get('pages').at(i).get('title').value}}</mat-panel-title> </button>
<div class="btn-group pull-right"> </div>
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeletePage(i);"> </mat-step>
<span class="glyphicon glyphicon-erase"></span> <mat-step>
</button>
</div> <div>
</mat-expansion-panel-header> <mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
<div id="{{'p' + i}}"> <mat-expansion-panel-header>
<div> <mat-panel-title *ngIf="form.get('sections').get(''+i).get('title').value && !panel.expanded">{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title>
<page-form [form]="form.get('pages').at(i)" [dataModel]="page"></page-form> <div class="btn-group pull-right">
</div> <button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteSection(i);">
</div> <span class="glyphicon glyphicon-erase"></span>
</mat-expansion-panel> </button>
</div> </div>
</mat-expansion-panel-header>
<div style="margin-top:20px; padding-left: 15px;" class="row"> <div id="{{'s' + i}}" *ngIf="panel.expanded">
<a (click)="addSection()" style="cursor: pointer"> <div>
Add Section + <section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="'s' + i"></section-form>
</a>
</div> </div>
</div>
</mat-expansion-panel>
</div>
<div style="margin-top:20px; padding-left: 15px;" class="row">
<a (click)="addPage()" style="cursor: pointer">
Add Page +
</a>
</div>
<button mat-raised-button color="primary" type="submit" [disabled]="!form.valid">Save</button>
</form> <div style="margin-top:20px; padding-left: 15px;" class="row">
</mat-card> <button mat-button (click)="addSection()" style="cursor: pointer">
</div> Add Section +
</button>
</div>
</mat-step>
</mat-horizontal-stepper>
<button mat-button (click)="preview()">Preview</button>
</div>

View File

@ -1,3 +1,3 @@
.full-width { .full-width {
width: 100%; width: 100%;
} }

View File

@ -10,6 +10,8 @@ import { Router, ActivatedRoute, ParamMap, Params } from '@angular/router';
import { PageFormComponent } from '../page-form/page-component' import { PageFormComponent } from '../page-form/page-component'
import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service'; import { DatasetProfileAdmin } from '../../services/datasetProfileAdmin/datasetProfileAfmin.service';
import { Section } from '../../models/datasetProfileAdmin/Section'; import { Section } from '../../models/datasetProfileAdmin/Section';
import { MatDialog } from '@angular/material';
import { DatasetProfilePreviewerComponent } from '../previewer/dataset-profile-previewer.component';
@Component({ @Component({
selector: 'form-comp', selector: 'form-comp',
@ -24,8 +26,13 @@ export class FormComponent {
form: FormGroup; form: FormGroup;
private profileID: string; private profileID: string;
constructor(public datasetprofileAdmin: DatasetProfileAdmin, private datasetProfileService: DatasetProfileService, private route: ActivatedRoute, constructor(
private router: Router) { public datasetprofileAdmin: DatasetProfileAdmin,
private datasetProfileService: DatasetProfileService,
private route: ActivatedRoute,
private router: Router,
public dialog: MatDialog,
) {
this.profileID = route.snapshot.params['id']; this.profileID = route.snapshot.params['id'];
} }
@ -41,7 +48,7 @@ export class FormComponent {
} }
else { else {
this.addSection(); this.addSection();
this.addPage(0); this.addPage();
} }
} }
@ -58,7 +65,7 @@ export class FormComponent {
(<FormArray>this.form.get("sections")).push(section.buildForm()); (<FormArray>this.form.get("sections")).push(section.buildForm());
} }
addPage(number) { addPage() {
let page: Page = new Page(this.dataModel.pages.length); let page: Page = new Page(this.dataModel.pages.length);
this.dataModel.pages.push(page); this.dataModel.pages.push(page);
(<FormArray>this.form.get("pages")).push(page.buildForm()); (<FormArray>this.form.get("pages")).push(page.buildForm());
@ -91,4 +98,14 @@ export class FormComponent {
}); });
} }
} preview() {
let dialogRef = this.dialog.open(DatasetProfilePreviewerComponent, {
height: '355px',
width: '700px',
data: {
model: this.dataModel
}
});
}
}

View File

@ -1,8 +1,9 @@
<div> <div [formGroup]="form">
<div [formGroup]="form" class="row"> <div fxLayout="row">
<div class="col-md-4"> <div fxFlex>
<label>Title</label> <mat-form-field class="full-width">
<input type="text" class="form-control" formControlName="title"> <input matInput type="text" placeholder="Title" formControlName="title">
</div> </mat-form-field>
</div> </div>
</div> </div>
</div>

View File

@ -0,0 +1,3 @@
.full-width {
width: 100%;
}

View File

@ -6,7 +6,7 @@ import { Page } from '../../models/datasetProfileAdmin/Page';
@Component({ @Component({
selector: 'page-form', selector: 'page-form',
templateUrl: './page-component.html', templateUrl: './page-component.html',
styleUrls: [] styleUrls: ['./page-component.scss']
}) })
export class PageFormComponent { export class PageFormComponent {
@ -16,4 +16,4 @@ export class PageFormComponent {
TargetValidation() { TargetValidation() {
} }
} }

View File

@ -0,0 +1,2 @@
<dynamic-form *ngIf="formGroup" [form]="this.formGroup"
[dataModel]="datasetWizardModel"></dynamic-form>

View File

@ -0,0 +1,36 @@
import { ViewEncapsulation, Component, Inject } from "@angular/core";
import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material";
import { FormGroup } from "@angular/forms";
import { DatasetProfileDefinitionModel } from "../../models/DatasetProfileDefinitionModel";
import { JsonSerializer } from "../../utilities/JsonSerializer";
import { DatasetModel } from "../../models/datasets/DatasetModel";
import { DatasetWizardModel } from "../../models/datasets/DatasetWizardModel";
import { DatasetProfileService } from "../../services/dataset-profile.service";
import { DatasetProfileAdmin } from "../../services/datasetProfileAdmin/datasetProfileAfmin.service";
@Component({
selector: 'dataset-profile-previewer',
templateUrl: './dataset-profile-previewer.component.html',
styleUrls: ['./dataset-profile-previewer.component.scss'],
encapsulation: ViewEncapsulation.None
})
export class DatasetProfilePreviewerComponent {
formGroup: FormGroup
datasetWizardModel: DatasetWizardModel
constructor(
private datasetProfileAdminService: DatasetProfileAdmin,
public dialogRef: MatDialogRef<DatasetProfilePreviewerComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { }
ngOnInit(): void {
this.datasetProfileAdminService.preview(this.data['model']).subscribe(x => {
this.datasetWizardModel = new DatasetWizardModel();
this.datasetWizardModel.datasetProfileDefinition = JsonSerializer.fromJSONObject(x, DatasetProfileDefinitionModel)
this.formGroup = this.datasetWizardModel.buildForm();
})
}
}

View File

@ -1,23 +1,23 @@
<div [formGroup]="form"> <div [formGroup]="form">
<div class="container"> <div>
<div class="row"> <div fxLayout="row">
<div class="col-md-6"> <div fxFlex>
<mat-form-field> <mat-form-field class="full-width">
<mat-select placeholder="Rule Type" formControlName="ruleType"> <mat-select placeholder="Rule Type" formControlName="ruleType">
<mat-option>field value</mat-option> <mat-option>field value</mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-md-6"> <div fxFlex>
<mat-form-field> <mat-form-field class="full-width">
<input matInput type="text" placeholder="Target" formControlName="target" (change)="TargetValidation()"> <input matInput type="text" placeholder="Target" formControlName="target" (change)="TargetValidation()">
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-md-12"> <div fxFlex>
<mat-form-field> <mat-form-field class="full-width">
<input matInput type="text" placeholder="Value" formControlName="value"> <input matInput type="text" placeholder="Value" formControlName="value">
</mat-form-field> </mat-form-field>
</div> </div>
</div>
</div> </div>
</div> </div>
</div>

View File

@ -0,0 +1,3 @@
.full-width {
width: 100%;
}

View File

@ -1,43 +1,59 @@
<div> <div [formGroup]="form">
<div class="row" [formGroup]="form"> <div fxLayout="row">
<div class="col-md-6"> <h4 style="font-weight: bold">Section Description</h4>
<mat-form-field class="full-width"> <div>
<input matInput type="text" placeholder="Title" formControlName="title"> <button mat-button (click)="addSectioninSection()" style="cursor: pointer">
</mat-form-field> Add Nested Section +
</button>
</div>
</div>
<div fxLayout="row" fxLayoutAlign="space-between center">
<div fxFlex>
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput type="text" placeholder="Id" formControlName="id"> <input matInput type="text" placeholder="Id" formControlName="id">
</mat-form-field> </mat-form-field>
</div>
<div fxFlex>
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<input matInput type="number" placeholder="Ordinal" formControlName="ordinal"> <input matInput type="text" placeholder="Title" formControlName="title">
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-md-6"> <div fxFlex>
<mat-form-field class="full-width"> <mat-form-field class="full-width">
<mat-select placeholder='Page' formControlName="page"> <mat-select placeholder='Page' formControlName="page" required>
<mat-option *ngFor="let pageGroup of form.root.get('pages')['controls'];" [value]="pageGroup.get('id').value">{{pageGroup.get('title').value}}</mat-option> <mat-option *ngFor="let pageGroup of form.root.get('pages')['controls'];" [value]="pageGroup.get('id').value">{{pageGroup.get('title').value}}</mat-option>
</mat-select> </mat-select>
<!-- <div *ngIf="form.get('page').invalid && (form.get('page').dirty || form.get('page').touched)" class="alert alert-danger">Page is required</div> --> <!-- <div *ngIf="form.get('page').invalid && (form.get('page').dirty || form.get('page').touched)" class="alert alert-danger">Page is required</div> -->
</mat-form-field> </mat-form-field>
</div>
</div>
<div fxLayout="row" fxLayoutAlign="start center">
<div fxFlex="10%">
<mat-form-field class="full-width">
<input matInput type="number" placeholder="Ordinal" formControlName="ordinal">
</mat-form-field>
</div>
<div fxFlex="50%">
<label>Default Visibility</label> <label>Default Visibility</label>
<mat-radio-group formControlName="defaultVisibility" class="full-width"> <mat-radio-group formControlName="defaultVisibility" class="full-width">
<mat-radio-button [value]="true">true</mat-radio-button> <mat-radio-button [value]="true">true</mat-radio-button>
<mat-radio-button [value]="false">false</mat-radio-button> <mat-radio-button [value]="false">false</mat-radio-button>
</mat-radio-group> </mat-radio-group>
</div> </div>
</div> </div>
<div *ngIf="dataModel.sections.length > 0"> <div *ngIf="dataModel.sections.length > 0">
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;"> <mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<mat-panel-title *ngIf="form.get('sections').get(''+i).get('title').value">{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title> <mat-panel-title *ngIf="form.get('sections').get(''+i).get('title').value && !panel.expanded">{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteSectionInSection(i);"> <button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteSectionInSection(i);">
<span class="glyphicon glyphicon-erase"></span> <span class="glyphicon glyphicon-erase"></span>
</button> </button>
</div> </div>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<div id="{{indexPath + 's' + i}}"> <div id="{{indexPath + 's' + i}}" *ngIf="panel.expanded">
<section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="indexPath + 's' + i"></section-form> <section-form [form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="indexPath + 's' + i"></section-form>
</div> </div>
</mat-expansion-panel> </mat-expansion-panel>
@ -52,13 +68,22 @@
</div> --> </div> -->
<div> <div>
<mat-expansion-panel *ngFor="let field of dataModel.fieldSets let i=index;" class="panel panel-default"> <div fxLayout="row">
<h4>Field Sets</h4>
<div>
<button mat-button (click)="addField()" style="cursor: pointer">
Add Field +
</button>
</div>
</div>
<mat-expansion-panel *ngFor="let field of dataModel.fieldSets let i=index;" class="panel panel-default" #panel>
<mat-expansion-panel-header> <mat-expansion-panel-header>
<!-- <a *ngIf="form.get('compositeFields').get(''+i).get('title').value" data-toggle="collapse" href="#{{'compositeFieldCollapse' + i}}" <!-- <a *ngIf="form.get('compositeFields').get(''+i).get('title').value" data-toggle="collapse" href="#{{'compositeFieldCollapse' + i}}"
class="panel-title pull-left" style="padding-top: 7.5px;">{{i + 1}}. {{form.get('compositeFields').get(''+i).get('title').value}}</a> class="panel-title pull-left" style="padding-top: 7.5px;">{{i + 1}}. {{form.get('compositeFields').get(''+i).get('title').value}}</a>
<a *ngIf="!form.get('compositeFields').get(''+i).get('title').value" data-toggle="collapse" href="#{{'compositeFieldCollapse' + i}}" <a *ngIf="!form.get('compositeFields').get(''+i).get('title').value" data-toggle="collapse" href="#{{'compositeFieldCollapse' + i}}"
class="panel-title pull-left" style="padding-top: 7.5px;">{{i + 1}}. Field {{i + 1}}</a> --> class="panel-title pull-left" style="padding-top: 7.5px;">{{i + 1}}. Field {{i + 1}}</a> -->
<mat-panel-title>{{i + 1}}. Field {{i + 1}}</mat-panel-title> <mat-panel-title *ngIf="!panel.expanded">{{i + 1}}. Field {{i + 1}}</mat-panel-title>
<div> <div>
<button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteFieldSet(i);"> <button type="button" class="btn btn-sm" style="margin-left:5px;" (click)="DeleteFieldSet(i);">
@ -67,7 +92,7 @@
</div> </div>
</mat-expansion-panel-header> </mat-expansion-panel-header>
<compositefield-form [form]="form.get('fieldSets').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'cf' + i"></compositefield-form> <compositefield-form *ngIf="panel.expanded" [form]="form.get('fieldSets').get(''+i)" [dataModel]="field" [indexPath]="indexPath + 'cf' + i"></compositefield-form>
</mat-expansion-panel> </mat-expansion-panel>
</div> </div>
@ -98,14 +123,5 @@
Add Group + Add Group +
</a> </a>
</div> --> </div> -->
<div>
<a (click)="addField()" style="cursor: pointer">
Add Field +
</a>
</div>
<div>
<a (click)="addSectioninSection()" style="cursor: pointer">
Add Section +
</a>
</div>
</div> </div>

View File

@ -1,3 +1,3 @@
.full-width { .full-width {
width: 100%; width: 90%;
} }

View File

@ -23,10 +23,9 @@ export class SectionFormComponent {
constructor() { } constructor() { }
ngOnInit() { ngOnInit() {
var self = this; this.form.root.get("pages").valueChanges.subscribe(x =>
this.form.root.get("pages").valueChanges.subscribe(function (value) { this.keepPageSelectionValid(x)
self.keepPageSelectionValid(value); );
});
} }
addField() { addField() {

View File

@ -80,7 +80,7 @@
</ng-container> </ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row> <mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
<!-- (click)="rowClick(row.id)" --> <!-- (click)="rowClick(row.id)" -->
</mat-table> </mat-table>
@ -91,4 +91,4 @@
<button mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]="['/form'] "> <button mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]="['/form'] ">
<mat-icon class="mat-24">add</mat-icon> <mat-icon class="mat-24">add</mat-icon>
</button> </button>
</div> </div>

View File

@ -1,84 +1,99 @@
<div> <div class="container">
<h3>{{'DATASET-PUBLIC-LISTING.TITLE' | translate}} {{titlePrefix}}</h3> <div class="row">
<div class="col-md-2">
<app-facet (facetCriteriaChange)="onCriteriaChange($event)">
</app-facet>
</div>
<div class="col-md-10">
<div>
<h3>{{'DATASET-PUBLIC-LISTING.TITLE' | translate}} {{titlePrefix}}</h3>
<app-datasets-criteria-component [isPublic]='true'></app-datasets-criteria-component> <app-datasets-criteria-component [isPublic]='true'></app-datasets-criteria-component>
<mat-card class="mat-card"> <mat-card class="mat-card">
<mat-card-header> <mat-card-header>
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar> <mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
</mat-card-header> </mat-card-header>
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()"> <mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
<!-- Column Definition: Name --> <!-- Column Definition: Name -->
<ng-container cdkColumnDef="label"> <ng-container cdkColumnDef="label">
<mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DATASET-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header="label">{{'DATASET-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.label}}</mat-cell> <mat-cell *matCellDef="let row">{{row.label}}</mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Dmp --> <!-- Column Definition: Dmp -->
<ng-container cdkColumnDef="dmp"> <ng-container cdkColumnDef="dmp">
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|dmp:label">{{'DATASET-LISTING.COLUMNS.DMP' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header="|join|dmp:label">{{'DATASET-LISTING.COLUMNS.DMP' |
<mat-cell *matCellDef="let row"> {{row.dmp}} </mat-cell> translate}}</mat-header-cell>
</ng-container> <mat-cell *matCellDef="let row"> {{row.dmp}} </mat-cell>
</ng-container>
<!-- Column Definition: Profile --> <!-- Column Definition: Profile -->
<ng-container cdkColumnDef="profile"> <ng-container cdkColumnDef="profile">
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|profile:label">{{'DATASET-LISTING.COLUMNS.PROFILE' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header="|join|profile:label">{{'DATASET-LISTING.COLUMNS.PROFILE'
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell> | translate}}</mat-header-cell>
</ng-container> <mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
</ng-container>
<!-- Column Definition: Status --> <!-- Column Definition: Status -->
<ng-container cdkColumnDef="status"> <ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef >{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.status}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.status}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: DataRepositories --> <!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="dataRepositories"> <!-- <ng-container cdkColumnDef="dataRepositories">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DATAREPOSITORIES' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DATAREPOSITORIES' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.dataRepositories}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.dataRepositories}} </mat-cell>
</ng-container> --> </ng-container> -->
<!-- Column Definition: DataRepositories --> <!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="registries"> <!-- <ng-container cdkColumnDef="registries">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.REGISTRIES' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.REGISTRIES' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.registries}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.registries}} </mat-cell>
</ng-container> --> </ng-container> -->
<!-- Column Definition: DataRepositories --> <!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="services"> <!-- <ng-container cdkColumnDef="services">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.SERVICES' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.SERVICES' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.services}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.services}} </mat-cell>
</ng-container> --> </ng-container> -->
<!-- Column Definition: Status --> <!-- Column Definition: Status -->
<!-- <ng-container cdkColumnDef="status"> <!-- <ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.status}} <mat-cell *matCellDef="let row"> {{row.status}}
</mat-cell> </mat-cell>
</ng-container> --> </ng-container> -->
<!-- Column Definition: Description --> <!-- Column Definition: Description -->
<ng-container cdkColumnDef="description"> <ng-container cdkColumnDef="description">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.description}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.description}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Created --> <!-- Column Definition: Created -->
<ng-container cdkColumnDef="created"> <ng-container cdkColumnDef="created">
<mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DATASET-LISTING.COLUMNS.CREATED' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header="created">{{'DATASET-LISTING.COLUMNS.CREATED' |
<mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell> translate}}</mat-header-cell>
</ng-container> <mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row> <mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
<!-- (click)="rowClick(row.id)" --> <!-- (click)="rowClick(row.id)" -->
</mat-table> </mat-table>
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]"> <mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
</mat-paginator> </mat-paginator>
</mat-card> </mat-card>
</div>
</div>
</div> </div>
</div>

View File

@ -11,6 +11,7 @@ import { DatasetCriteria } from "../../models/criteria/dataset/DatasetCriteria";
import { DataSource } from "@angular/cdk/table"; import { DataSource } from "@angular/cdk/table";
import { DatasetListingModel } from "../../models/datasets/DatasetListingModel"; import { DatasetListingModel } from "../../models/datasets/DatasetListingModel";
import { DataTableRequest } from "../../models/data-table/DataTableRequest"; import { DataTableRequest } from "../../models/data-table/DataTableRequest";
import { FacetSearchCriteriaModel } from "../../models/facet-search/FacetSearchCriteriaModel";
@Component({ @Component({
@ -31,11 +32,6 @@ export class DatasetPublicListingComponent implements OnInit {
titlePrefix: String; titlePrefix: String;
dmpId: string; dmpId: string;
statuses = [
{ value: '0', viewValue: 'Active' },
{ value: '1', viewValue: 'Inactive' }
];
constructor( constructor(
private datasetService: DatasetService, private datasetService: DatasetService,
private router: Router, private router: Router,
@ -49,8 +45,6 @@ export class DatasetPublicListingComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.route.params.subscribe(async (params: Params) => { this.route.params.subscribe(async (params: Params) => {
this.dmpId = params['dmpId']; this.dmpId = params['dmpId'];
this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId)); this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId));
@ -64,6 +58,12 @@ export class DatasetPublicListingComponent implements OnInit {
}); });
} }
onCriteriaChange(event){
//console.log(event)
this.criteria.setCriteria(event);
this.refresh();
}
refresh() { refresh() {
this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId); this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, this.dmpId);
} }
@ -119,10 +119,10 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
const startIndex = this._paginator.pageIndex * this._paginator.pageSize; const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
let fields: Array<string> = new Array() let fields: Array<string> = new Array()
if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active];
const request = new DataTableRequest<DatasetCriteria>(startIndex, this._paginator.pageSize, { fields: fields }); const request = new DataTableRequest<FacetSearchCriteriaModel>(startIndex, this._paginator.pageSize, { fields: fields });
request.criteria = this._criteria.criteria; request.criteria = this._criteria.criteria;
if (this.dmpId) request.criteria.allVersions = true; //if (this.dmpId) request.criteria.allVersions = true;
return this._service.getPaged(request); return this._service.getPublicPaged(request);
}) })
/*.catch((error: any) => { /*.catch((error: any) => {
this._snackBar.openFromComponent(SnackBarNotificationComponent, { this._snackBar.openFromComponent(SnackBarNotificationComponent, {

View File

@ -17,21 +17,23 @@
<!-- Column Definition: Dmp --> <!-- Column Definition: Dmp -->
<ng-container cdkColumnDef="dmp"> <ng-container cdkColumnDef="dmp">
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|dmp:label">{{'DATASET-LISTING.COLUMNS.DMP' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header="|join|dmp:label">{{'DATASET-LISTING.COLUMNS.DMP' |
translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.dmp}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.dmp}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Profile --> <!-- Column Definition: Profile -->
<ng-container cdkColumnDef="profile"> <ng-container cdkColumnDef="profile">
<mat-header-cell *matHeaderCellDef mat-sort-header="|join|profile:label">{{'DATASET-LISTING.COLUMNS.PROFILE' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef mat-sort-header="|join|profile:label">{{'DATASET-LISTING.COLUMNS.PROFILE' |
translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.profile}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Status --> <!-- Column Definition: Status -->
<ng-container cdkColumnDef="status"> <ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef >{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.STATUS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"> {{row.status}} </mat-cell> <mat-cell *matCellDef="let row"> {{this.utilities.convertFromDatasetStatus(row.status)}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: DataRepositories --> <!-- Column Definition: DataRepositories -->
<!-- <ng-container cdkColumnDef="dataRepositories"> <!-- <ng-container cdkColumnDef="dataRepositories">
@ -76,9 +78,11 @@
<mat-cell *matCellDef="let row" (click)="$event.stopPropagation()"> <mat-cell *matCellDef="let row" (click)="$event.stopPropagation()">
<mat-menu #actionsMenu="matMenu"> <mat-menu #actionsMenu="matMenu">
<button *ngIf="row.status == 0" (click)="rowClick(row.id)" mat-menu-item> <button *ngIf="row.status == 0" (click)="rowClick(row.id)" mat-menu-item>
<mat-icon>mode_edit</mat-icon>{{'DATASET-LISTING.ACTIONS.EDIT' | translate}}</button> <mat-icon>mode_edit</mat-icon>{{'DATASET-LISTING.ACTIONS.EDIT' | translate}}
</button>
<button *ngIf="row.status != 0" (click)="makeItPublic(row.id)" mat-menu-item> <button *ngIf="row.status != 0" (click)="makeItPublic(row.id)" mat-menu-item>
<mat-icon>public</mat-icon>{{'DATASET-LISTING.ACTIONS.MAKE-IT-PUBLIC' | translate}}</button> <mat-icon>public</mat-icon>{{'DATASET-LISTING.ACTIONS.MAKE-IT-PUBLIC' | translate}}
</button>
</mat-menu> </mat-menu>
<button mat-icon-button [matMenuTriggerFor]="actionsMenu"> <button mat-icon-button [matMenuTriggerFor]="actionsMenu">

View File

@ -16,12 +16,15 @@ import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataM
import { DatasetCriteriaComponent } from '../../shared/components/criteria/datasets/datasets-criteria.component'; import { DatasetCriteriaComponent } from '../../shared/components/criteria/datasets/datasets-criteria.component';
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item'; import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent'; import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
import { Utilities } from '../../utilities/utilities';
import { JsonSerializer } from '../../utilities/JsonSerializer';
@Component({ @Component({
selector: 'app-dataset-listing-component', selector: 'app-dataset-listing-component',
templateUrl: 'dataset-listing.component.html', templateUrl: 'dataset-listing.component.html',
styleUrls: ['./dataset-listing.component.scss'], styleUrls: ['./dataset-listing.component.scss'],
providers:[Utilities]
}) })
export class DatasetListingComponent implements OnInit, IBreadCrumbComponent { export class DatasetListingComponent implements OnInit, IBreadCrumbComponent {
@ -48,7 +51,8 @@ export class DatasetListingComponent implements OnInit, IBreadCrumbComponent {
private languageService: TranslateService, private languageService: TranslateService,
public snackBar: MatSnackBar, public snackBar: MatSnackBar,
public route: ActivatedRoute, public route: ActivatedRoute,
public dataManagementPlanService: DataManagementPlanService public dataManagementPlanService: DataManagementPlanService,
public utilities: Utilities
) { ) {
} }
@ -141,6 +145,10 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
//this._criteria.criteria.onCallbackError(error); //this._criteria.criteria.onCallbackError(error);
return Observable.of(null); return Observable.of(null);
})*/ })*/
.map(result => {
result.data = JsonSerializer.fromJSONArray(result.data, DatasetListingModel)
return result;
})
.map(result => { .map(result => {
setTimeout(() => { setTimeout(() => {
this.isLoadingResults = false; this.isLoadingResults = false;

View File

@ -40,7 +40,8 @@ export class DataManagementPlanProfileEditorComponent implements AfterViewInit {
public snackBar: MatSnackBar, public snackBar: MatSnackBar,
public router: Router, public router: Router,
public language: TranslateService, public language: TranslateService,
private dialogService: TdDialogService private dialogService: TdDialogService,
private utilities: Utilities
) { ) {
} }
@ -153,7 +154,7 @@ export class DataManagementPlanProfileEditorComponent implements AfterViewInit {
getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string { getDMPProfileFieldDataTypeWithLanguage(role: DMPProfileFieldDataType): string {
let result = ''; let result = '';
this.language.get(new Utilities().convertFromDMPProfileDataType(role)).subscribe((value: string) => { this.language.get(this.utilities.convertFromDMPProfileDataType(role)).subscribe((value: string) => {
result = value; result = value;
}); });
return result; return result;
@ -168,7 +169,7 @@ export class DataManagementPlanProfileEditorComponent implements AfterViewInit {
getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string { getDMPProfileFieldTypeWithLanguage(role: DMPProfileType): string {
let result = ''; let result = '';
this.language.get(new Utilities().convertFromDMPProfileType(role)).subscribe((value: string) => { this.language.get(this.utilities.convertFromDMPProfileType(role)).subscribe((value: string) => {
result = value; result = value;
}); });
return result; return result;

View File

@ -17,6 +17,7 @@ import { DatasetRoutes } from '../../datasets/dataset.routes';
import { ProjectModel } from '../../models/projects/ProjectModel'; import { ProjectModel } from '../../models/projects/ProjectModel';
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent'; import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item'; import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
import { JsonSerializer } from '../../utilities/JsonSerializer';
@ -173,6 +174,10 @@ export class DataManagementPlanDataSource extends DataSource<DataManagementPlanL
}); });
return Observable.of(null); return Observable.of(null);
})*/ })*/
.map(result => {
result.data = JsonSerializer.fromJSONArray(result.data, DataManagementPlanListingModel)
return result;
})
.map(result => { .map(result => {
setTimeout(() => { setTimeout(() => {
this.isLoadingResults = false; this.isLoadingResults = false;

View File

@ -31,6 +31,7 @@ import { CommonModule } from '@angular/common';
import { NgModule } from "@angular/core"; import { NgModule } from "@angular/core";
import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service'; import { DatasetProfileAdmin } from '../services/datasetProfileAdmin/datasetProfileAfmin.service';
import { DatasetProfileService } from '../services/dataset-profile.service'; import { DatasetProfileService } from '../services/dataset-profile.service';
import { DatasetWizardService } from '../services/dataset-wizard/dataset-wizard.service';
@NgModule({ @NgModule({
@ -90,7 +91,8 @@ import { DatasetProfileService } from '../services/dataset-profile.service';
VisibilityRulesService, VisibilityRulesService,
PaginationService, PaginationService,
DatasetProfileService, DatasetProfileService,
DatasetProfileAdmin DatasetProfileAdmin,
DatasetWizardService
] ]
}) })

View File

@ -9,7 +9,7 @@ export class DataManagementPlanListingModel implements Serializable<DataManageme
public organisations: String; public organisations: String;
public groupId: string; public groupId: string;
public version: number; public version: number;
public datasets: any[]
fromJSONObject(item: any): DataManagementPlanListingModel { fromJSONObject(item: any): DataManagementPlanListingModel {
this.id = item.id; this.id = item.id;
this.label = item.label; this.label = item.label;
@ -18,7 +18,8 @@ export class DataManagementPlanListingModel implements Serializable<DataManageme
this.creationTime = item.creationTime; this.creationTime = item.creationTime;
this.organisations = item.organisations; this.organisations = item.organisations;
this.version = item.version; this.version = item.version;
this.groupId = item.groupId; this.groupId = item.groupId;
this.datasets = item.datasets;
return this; return this;
} }
} }

View File

@ -1,10 +1,10 @@
import { BaseModel } from '../BaseModel'; import { BaseModel } from '../BaseModel';
import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';
import { FormGenerator } from '../interfaces/FormGenerator'; import { FormGenerator } from '../interfaces/FormGenerator';
import { JsonSerializer } from 'app/utilities/JsonSerializer';
import { Section } from './Section'; import { Section } from './Section';
import { Serializable } from '../interfaces/Serializable'; import { Serializable } from '../interfaces/Serializable';
import { Page } from "./Page"; import { Page } from "./Page";
import { JsonSerializer } from '../../utilities/JsonSerializer';
export class DatasetProfileModelAdmin extends BaseModel implements Serializable<DatasetProfileModelAdmin>,FormGenerator<FormGroup>{ export class DatasetProfileModelAdmin extends BaseModel implements Serializable<DatasetProfileModelAdmin>,FormGenerator<FormGroup>{
@ -40,4 +40,4 @@ export class DatasetProfileModelAdmin extends BaseModel implements Serializable<
return formGroup; return formGroup;
} }
} }

View File

@ -1,33 +1,33 @@
import { Serializable } from "../Serializable"; import { Serializable } from "../Serializable";
export class DatasetListingModel implements Serializable<DatasetListingModel> { export class DatasetListingModel implements Serializable<DatasetListingModel> {
public id: String; public id: String;
public label:String; public label: String;
public dmp: String; public dmp: String;
public profile: String; public profile: String;
public dataRepositories: String; public dataRepositories: String;
public registries: String; public registries: String;
public services: String; public services: String;
public description: String; public description: String;
public status: Number; public status: Number;
public created: Date; public created: Date;
//public uri: String; //public uri: String;
// public reference: String; // public reference: String;
fromJSONObject(item: any): DatasetListingModel { fromJSONObject(item: any): DatasetListingModel {
this.id = item.id; this.id = item.id;
this.label = item.label; this.label = item.label;
this.dmp = item.dmp; this.dmp = item.dmp;
this.profile = item.profile; this.profile = item.profile;
this.dataRepositories = item.dataRepositories; this.dataRepositories = item.dataRepositories;
this.registries = item.registries; this.registries = item.registries;
this.services = item.services; this.services = item.services;
//this.reference = item.reference; //this.reference = item.reference;
//this.uri = item.uri; //this.uri = item.uri;
this.status = item.status; this.status = item.status;
this.description = item.description; this.description = item.description;
this.created = item.created; this.created = item.created;
return this; return this;
} }
} }

View File

@ -14,6 +14,11 @@ import { DataRepositoryModel } from "../dataRepositories/DataRepositoryModel";
import { ExternalDatasetModel } from '../../models/external-dataset/ExternalDatasetModel'; import { ExternalDatasetModel } from '../../models/external-dataset/ExternalDatasetModel';
import { TagModel } from '../tags/TagModel'; import { TagModel } from '../tags/TagModel';
export enum DatasetStatus {
Draft = 0,
Finalised = 1
}
export class DatasetWizardModel implements Serializable<DatasetWizardModel> { export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
public id: string; public id: string;
public label: string; public label: string;

View File

@ -0,0 +1,8 @@
import { ProjectStateType } from "../projects/ProjectStateType";
export class FacetSearchCriteriaModel {
public projectStatus: ProjectStateType;
public projects: string[] = [];
public datasetProfile: string[] = [];
public dmpOrganisations: string[] = [];
}

View File

@ -24,11 +24,11 @@ export class ProjectListingModel implements Serializable<ProjectListingModel> {
this.reference = item.reference; this.reference = item.reference;
this.uri = item.uri; this.uri = item.uri;
this.status = item.status; this.status = item.status;
this.startDate = item.startdate ? new Date(item.startdate) : item.startDate; this.startDate = item.startDate ? new Date(item.startDate) : item.startDate;
this.endDate = item.enddate ? new Date(item.enddate) : item.endDate; this.endDate = item.endDate ? new Date(item.endDate) : item.endDate;
this.description = item.description; this.description = item.description;
this.files = JsonSerializer.fromJSONArray(item.files, ContentFile) this.files = JsonSerializer.fromJSONArray(item.files, ContentFile)
this.dmps = JsonSerializer.fromJSONArray(item.dmps, UrlListingItem) this.dmps = JsonSerializer.fromJSONArray(item.dmps, UrlListingItem)
return this; return this;
} }
} }

View File

@ -15,6 +15,7 @@ import { LanguageResolverService } from '../../services/language-resolver/langua
import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item'; import { BreadcrumbItem } from '../../shared/components/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent'; import { IBreadCrumbComponent } from '../../shared/components/breadcrumb/definition/IBreadCrumbComponent';
import { ProjectStateType } from '../../models/projects/ProjectStateType'; import { ProjectStateType } from '../../models/projects/ProjectStateType';
import { JsonSerializer } from '../../utilities/JsonSerializer';
@Component({ @Component({
selector: 'app-project-listing-component', selector: 'app-project-listing-component',
@ -120,6 +121,10 @@ export class ProjectDataSource extends DataSource<ProjectListingModel> {
this._criteria.onCallbackError(error.error); this._criteria.onCallbackError(error.error);
return Observable.of(null); return Observable.of(null);
})*/ })*/
.map(result => {
result.data = JsonSerializer.fromJSONArray(result.data, ProjectListingModel)
return result;
})
.map(result => { .map(result => {
setTimeout(() => { setTimeout(() => {
this.isLoadingResults = false; this.isLoadingResults = false;

View File

@ -10,34 +10,39 @@ import { DatasetListingModel } from '../../models/datasets/DatasetListingModel';
import { DatasetModel } from '../../models/datasets/DatasetModel'; import { DatasetModel } from '../../models/datasets/DatasetModel';
import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria'; import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria';
import { DatasetProfileModel } from '../../models/datasetprofile/DatasetProfileModel'; import { DatasetProfileModel } from '../../models/datasetprofile/DatasetProfileModel';
import { FacetSearchCriteriaModel } from '../../models/facet-search/FacetSearchCriteriaModel';
@Injectable() @Injectable()
export class DatasetService { export class DatasetService {
private actionUrl: string; private actionUrl: string;
private headers: HttpHeaders; private headers: HttpHeaders;
constructor(private http: BaseHttpService) { constructor(private http: BaseHttpService) {
this.actionUrl = HostConfiguration.Server + 'datasets/'; this.actionUrl = HostConfiguration.Server + 'datasets/';
this.headers = new HttpHeaders(); this.headers = new HttpHeaders();
this.headers = this.headers.set('Content-Type', 'application/json'); this.headers = this.headers.set('Content-Type', 'application/json');
this.headers = this.headers.set('Accept', 'application/json'); this.headers = this.headers.set('Accept', 'application/json');
} }
getPaged(dataTableRequest: DataTableRequest<DatasetCriteria>): Observable<DataTableData<DatasetListingModel>> { getPaged(dataTableRequest: DataTableRequest<DatasetCriteria>): Observable<DataTableData<DatasetListingModel>> {
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
} }
makeDatasetPublic(id: String) { getPublicPaged(dataTableRequest: DataTableRequest<FacetSearchCriteriaModel>): Observable<DataTableData<DatasetListingModel>> {
return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }) return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'public/paged', dataTableRequest, { headers: this.headers });
} }
getDatasetProfiles(): Observable<DatasetProfileModel[]> { makeDatasetPublic(id: String) {
return this.http.get<DatasetProfileModel[]>(HostConfiguration.Server + 'datasetprofiles/getAll', { headers: this.headers }) return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers })
} }
getDatasetProfiles(): Observable<DatasetProfileModel[]> {
return this.http.get<DatasetProfileModel[]>(HostConfiguration.Server + 'datasetprofiles/getAll', { headers: this.headers })
}
} }

View File

@ -42,4 +42,8 @@ export class DatasetProfileAdmin {
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest, { headers: this.headers }); return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest, { headers: this.headers });
} }
preview(data: DatasetProfileModelAdmin): Observable<DatasetProfileModelAdmin> {
return this.http.post<DatasetProfileModelAdmin>(this.actionUrl + 'preview', data, { headers: this.headers });
}
} }

Some files were not shown because too many files have changed in this diff Show More