This commit is contained in:
Diamantis Tziotzios 2020-05-11 13:49:48 +03:00
commit 36ef691e1e
122 changed files with 2067 additions and 1129 deletions

View File

@ -0,0 +1 @@
PROFILE=staging

View File

@ -1,11 +1,23 @@
FROM openjdk:8-jdk-alpine
RUN apk add --update \
curl \
&& rm -rf /var/cache/apk/*
VOLUME /tmp
ARG PROFILE=production
ENV PROF $PROFILE
ADD web/src/main/resources/ProjectConfiguration.xml /tmp/ProjectConfiguration.xml
ADD web/src/main/resources/ExternalUrls.xml /tmp/ExternalUrls.xml
ADD web/target/web-1.0-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-Dspring.profiles.active=${PROF}","-jar","/app.jar"]
FROM maven:3-jdk-8-alpine AS MAVEN_BUILD
COPY pom.xml /build/
COPY data /build/data/
COPY elastic /build/elastic/
COPY logging /build/logging/
COPY queryable /build/queryable/
COPY web /build/web/
WORKDIR /build/
RUN mvn package
FROM openjdk:8-jre-alpine
WORKDIR /app
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app/app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom" ,"-Dspring.profiles.active=${PROFILE}","-jar","/app/app.jar"]

View File

@ -33,6 +33,7 @@ public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
private Short filter;
private UUID userId;
private boolean finalized;
private Integer status;
public boolean getAllVersions() { return allVersions; }
public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
@ -60,4 +61,12 @@ public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
public void setFinalized(boolean finalized) {
this.finalized = finalized;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}

View File

@ -52,6 +52,9 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implem
builder.notEqual(root.get("id"), criteria.getUserId())));
}
}
if (criteria.getStatus() != null) {
query.where(((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())));
}
if (criteria.getFinalized()) {
query.where(((builder, root) -> builder.equal(root.get("status"), DatasetProfile.Status.FINALIZED.getValue())));
} else {

View File

@ -0,0 +1,11 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DoiFunder;
import java.util.UUID;
public interface DoiFunderDao extends DatabaseAccessLayer<DoiFunder, UUID> {
DoiFunder findFunderByName(String name);
}

View File

@ -0,0 +1,55 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.DoiFunder;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("DoiFunderDao")
public class DoiFunderDaoImpl extends DatabaseAccess<DoiFunder> implements DoiFunderDao {
@Autowired
public DoiFunderDaoImpl(DatabaseService<DoiFunder> databaseService) {
super(databaseService);
}
@Override
public DoiFunder findFunderByName(String name) {
return this.asQueryable().toList().stream().filter(doiFunder -> name.contains(doiFunder.getName()) || doiFunder.getName().contains(name)).findFirst().orElse(null);
}
@Override
public DoiFunder createOrUpdate(DoiFunder item) {
return this.getDatabaseService().createOrUpdate(item, DoiFunder.class);
}
@Override
public CompletableFuture<DoiFunder> createOrUpdateAsync(DoiFunder item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public DoiFunder find(UUID id) {
return this.getDatabaseService().getQueryable(DoiFunder.class).where(((builder, root) -> builder.equal(root.get("id"), id))).getSingle();
}
@Override
public DoiFunder find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(DoiFunder item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<DoiFunder> asQueryable() {
return this.getDatabaseService().getQueryable(DoiFunder.class);
}
}

View File

@ -0,0 +1,15 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserInfo;
import java.util.List;
import java.util.UUID;
public interface UserAssociationDao extends DatabaseAccessLayer<UserAssociation, UUID> {
public List<UserAssociation> getAssociated(UserInfo userId);
public Boolean areAssociated(UserInfo firstUser, UserInfo secondUser);
}

View File

@ -0,0 +1,73 @@
package eu.eudat.data.dao.entities;
import eu.eudat.data.dao.DatabaseAccess;
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@Component("UserAssociationDao")
public class UserAssociationDaoImpl extends DatabaseAccess<UserAssociation> implements UserAssociationDao {
@Autowired
public UserAssociationDaoImpl(DatabaseService<UserAssociation> databaseService) {
super(databaseService);
}
@Override
public UserAssociation createOrUpdate(UserAssociation item) {
return this.getDatabaseService().createOrUpdate(item, UserAssociation.class);
}
@Override
public CompletableFuture<UserAssociation> createOrUpdateAsync(UserAssociation item) {
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
}
@Override
public UserAssociation find(UUID id) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) -> builder.equal(root.get("id"), id))).getSingle();
}
@Override
public UserAssociation find(UUID id, String hint) {
throw new UnsupportedOperationException();
}
@Override
public void delete(UserAssociation item) {
this.getDatabaseService().delete(item);
}
@Override
public QueryableList<UserAssociation> asQueryable() {
return this.getDatabaseService().getQueryable(UserAssociation.class);
}
@Override
public List<UserAssociation> getAssociated(UserInfo userId) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) ->
builder.or(builder.equal(root.get("firstUser"), userId), builder.equal(root.get("secondUser"), userId)))).toList();
}
@Override
public Boolean areAssociated(UserInfo firstUser, UserInfo secondUser) {
return this.getDatabaseService().getQueryable(UserAssociation.class).where(((builder, root) ->
builder.or(
builder.and(
builder.equal(root.get("firstUser"), firstUser),
builder.equal(root.get("secondUser"), secondUser)
),
builder.and(
builder.equal(root.get("secondUser"), firstUser),
builder.equal(root.get("firstUser"), secondUser)
)
))).count() > 0;
}
}

View File

@ -0,0 +1,61 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"DoiFunder\"")
public class DoiFunder implements DataEntity<DoiFunder, UUID> {
@Id
private UUID id;
@Column(name = "name")
private String name;
@Column(name = "doi")
private String doi;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDoi() {
return doi;
}
public void setDoi(String doi) {
this.doi = doi;
}
@Override
public void update(DoiFunder entity) {
this.name = entity.name;
this.doi = entity.doi;
}
@Override
public UUID getKeys() {
return id;
}
@Override
public DoiFunder buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -0,0 +1,66 @@
package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"UserAssociation\"")
public class UserAssociation implements DataEntity<UserAssociation, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"firstUser\"")
private UserInfo firstUser;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"secondUser\"")
private UserInfo secondUser;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UserInfo getFirstUser() {
return firstUser;
}
public void setFirstUser(UserInfo firstUser) {
this.firstUser = firstUser;
}
public UserInfo getSecondUser() {
return secondUser;
}
public void setSecondUser(UserInfo secondUser) {
this.secondUser = secondUser;
}
@Override
public void update(UserAssociation entity) {
}
@Override
public UUID getKeys() {
return null;
}
@Override
public UserAssociation buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
return null;
}
}

View File

@ -82,13 +82,9 @@ public class DMPs extends BaseController {
this.configLoader = configLoader;
}
/*@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
this.dataManagementPlanManager.unlock(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
}*/
/*
* Data Retrieval
* */
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
@ -102,11 +98,11 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"{id}"})
public @ResponseBody
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, InstantiationException, IOException {
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
if (contentType.equals("application/xml") || contentType.equals("application/msword")) {
return this.dataManagementPlanManager.getDocument(id, contentType, principal, this.configLoader);
} else {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal);
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, false);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
}
@ -118,17 +114,11 @@ public class DMPs extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
}
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
public @ResponseBody
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IOException {
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, principal);
}
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSingle(@PathVariable String id,@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal);
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, false);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
} catch (Exception e) {
if (e instanceof UnauthorisedException) {
@ -141,26 +131,71 @@ public class DMPs extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
public @ResponseBody
ResponseEntity getSinglePublic(@PathVariable String id) {
try {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSinglePublic(id, this.dynamicGrantConfiguration);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
} catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
}
ResponseEntity getSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
// try {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
// } catch (Exception ex) {
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
// }
}
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSinglePublic(@PathVariable String id) {
try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSinglePublic(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
} catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
}
ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
// try {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, true);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
// } catch (Exception ex) {
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
// }
}
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
/*
* Data Export
* */
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
public @ResponseBody
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IOException {
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, principal);
}
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, principal, configLoader);
String name = file.getFilename().substring(0, file.getFilename().length() - 5);
File pdffile = datasetManager.convertToPDF(file, environment);
InputStream resource = new FileInputStream(pdffile);
logger.info("Mime Type of " + name + " is " +
new MimetypesFileTypeMap().getContentType(file.getFile()));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + name + ".pdf");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
resource.close();
Files.deleteIfExists(file.getFile().toPath());
Files.deleteIfExists(pdffile.toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
/*
* Data Management
* */
@Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
@ -199,37 +234,6 @@ public class DMPs extends BaseController {
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, principal, configLoader);
String name = file.getFilename().substring(0, file.getFilename().length() - 5);
File pdffile = datasetManager.convertToPDF(file, environment);
InputStream resource = new FileInputStream(pdffile);
logger.info("Mime Type of " + name + " is " +
new MimetypesFileTypeMap().getContentType(file.getFile()));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + name + ".pdf");
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
resource.close();
Files.deleteIfExists(file.getFile().toPath());
Files.deleteIfExists(pdffile.toPath());
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<ResponseItem> dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception {
if (files[0].getContentType().equals(APPLICATION_JSON.toString())) {
@ -241,29 +245,6 @@ public class DMPs extends BaseController {
.status(ApiMessageCode.SUCCESS_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal,
@RequestParam String fieldsGroup) throws Exception {
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
@RequestMapping(method = RequestMethod.POST, value = {"/test"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<Map>>> test(@RequestBody DMPCriteria criteria, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
DatabaseRepository dbRepo = this.getApiContext().getOperationsContext().getDatabaseRepository();
DMPQuery query = criteria.buildQuery(dbRepo);
List<Map> models = query.getQuery().toListWithFields();
DataTableData<Map> dmp = new DataTableData<>();
dmp.setData(models);
dmp.setTotalCount(query.getQuery().count());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Map>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"})
public ResponseEntity<ResponseItem<DMP>> makePublic(@PathVariable String id, Principal principal) {
try {
@ -285,6 +266,10 @@ public class DMPs extends BaseController {
}
}
/*
* DOI Generation
* */
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/createZenodoDoi/{id}"})
public ResponseEntity<ResponseItem<String>> createZenodoDoi(@PathVariable String id, Principal principal) {
@ -297,7 +282,11 @@ public class DMPs extends BaseController {
}
}
@javax.transaction.Transactional
/*
* Data Index
* */
@Transactional
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> generateIndex(Principal principal) throws Exception {
@ -305,11 +294,45 @@ public class DMPs extends BaseController {
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
}
@javax.transaction.Transactional
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
public @ResponseBody
ResponseEntity<ResponseItem<Dataset>> clearIndex(Principal principal) throws Exception {
this.dataManagementPlanManager.clearIndex(principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
}
/*
* Misc
* */
@RequestMapping(method = RequestMethod.POST, value = {"/test"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<Map>>> test(@RequestBody DMPCriteria criteria, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
DatabaseRepository dbRepo = this.getApiContext().getOperationsContext().getDatabaseRepository();
DMPQuery query = criteria.buildQuery(dbRepo);
List<Map> models = query.getQuery().toListWithFields();
DataTableData<Map> dmp = new DataTableData<>();
dmp.setData(models);
dmp.setTotalCount(query.getQuery().count());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Map>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
/*@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest,
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal,
@RequestParam String fieldsGroup) throws Exception {
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}*/
/*@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
this.dataManagementPlanManager.unlock(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
}*/
}

View File

@ -48,8 +48,8 @@ public class UserInvitationController extends BaseController {
@RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException {
List<UserInfoInvitationModel> users = invitationsManager.getUsers(userInfoRequestItem);
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(Principal principal) throws IllegalAccessException, InstantiationException {
List<UserInfoInvitationModel> users = invitationsManager.getUsers(principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users));
}
}

View File

@ -0,0 +1,19 @@
package eu.eudat.exceptions.security;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.FORBIDDEN)
public class ForbiddenException extends RuntimeException {
public ForbiddenException() {
super();
}
public ForbiddenException(String message) {
super(message);
}
public ForbiddenException(String message, Throwable cause) {
super(message, cause);
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.logic.managers;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.UserAssociation;
import eu.eudat.data.entities.UserDMP;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.exceptions.security.UnauthorisedException;
@ -38,15 +39,28 @@ public class InvitationsManager {
UserDMP userDMP = new UserDMP();
userDMP.setUser(userInfo);
userInfoToUserDmp.add(userDMP);
if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(principalUser, userInfo)) {
UserAssociation userAssociation = new UserAssociation();
userAssociation.setFirstUser(principalUser);
userAssociation.setSecondUser(userInfo);
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
}
}
DMP dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(item -> item.toDataModel()).collect(Collectors.toList()), dataManagementPlan, principalUser);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan);
}
public List<UserInfoInvitationModel> getUsers(UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
QueryableList<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoRequestItem.getCriteria());
List<UserInfoInvitationModel> userModels = users.select(item -> new UserInfoInvitationModel().fromDataModel(item));
public List<UserInfoInvitationModel> getUsers(Principal principal) throws InstantiationException, IllegalAccessException {
UserInfo principalUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().getAssociated(principalUser).stream().map(userAssociation -> {
if (userAssociation.getFirstUser().getId().equals(principal.getId())) {
return userAssociation.getSecondUser();
} else {
return userAssociation.getFirstUser();
}
}).collect(Collectors.toList());
List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
return userModels;
}
@ -60,6 +74,12 @@ public class InvitationsManager {
userDMP.setUser(invitedUser);
userDMP.setDmp(invitation.getDmp());
userDMP.setRole(UserDMP.UserDMPRoles.USER.getValue());
if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(invitedUser, invitation.getUser())) {
UserAssociation userAssociation = new UserAssociation();
userAssociation.setFirstUser(invitedUser);
userAssociation.setSecondUser(invitation.getUser());
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
}
DMP datamanagementPlan = invitation.getDmp();
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userDMP, datamanagementPlan);

View File

@ -32,7 +32,7 @@ public class RDAManager {
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss Z"));
result = mapper.writeValueAsString(rdaDmp);
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rdaDmp);
return result;
}

View File

@ -169,9 +169,13 @@ public class RemoteFetcher {
completedPath = completedPath.replace("{like}", "");
}
if (externalUrlCriteria.getFunderId() != null) {
String funderId = externalUrlCriteria.getFunderId();
String funderPrefix = externalUrlCriteria.getFunderId().split(":")[0];
String funderId = externalUrlCriteria.getFunderId().replace(funderPrefix + ":", "");
if (funderId.toCharArray()[0] == ':') {
funderId = externalUrlCriteria.getFunderId();
}
try {
funderId = URLEncoder.encode(externalUrlCriteria.getFunderId(), "UTF-8");
funderId = URLEncoder.encode(funderId, "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.error(e.getMessage(), e);
}

View File

@ -56,5 +56,9 @@ public interface DatabaseRepository {
NotificationDao getNotificationDao();
UserAssociationDao getUserAssociationDao();
DoiFunderDao getDoiFunderDao();
<T> void detachEntity(T entity);
}

View File

@ -37,6 +37,8 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
private FunderDao funderDao;
private LockDao lockDao;
private NotificationDao notificationDao;
private UserAssociationDao userAssociationDao;
private DoiFunderDao doiFunderDao;
private EntityManager entityManager;
@ -290,6 +292,26 @@ public class DatabaseRepositoryImpl implements DatabaseRepository {
return notificationDao;
}
@Override
public UserAssociationDao getUserAssociationDao() {
return userAssociationDao;
}
@Override
public DoiFunderDao getDoiFunderDao() {
return doiFunderDao;
}
@Autowired
public void setDoiFunderDao(DoiFunderDao doiFunderDao) {
this.doiFunderDao = doiFunderDao;
}
@Autowired
public void setUserAssociationDao(UserAssociationDao userAssociationDao) {
this.userAssociationDao = userAssociationDao;
}
@Autowired
public void setNotificationDao(NotificationDao notificationDao) {
this.notificationDao = notificationDao;

View File

@ -134,10 +134,10 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer
.name(profile.getName()).verified_email(profile.getIsVerified())
.email(profile.getEmail()).created(new Date()).lastloggedin(new Date())
.additionalinfo("{\"data\":{\"avatar\":{\"url\":\"" + profile.getAvatarUrl()
+ "\"}},{\"zenodoToken\":\"" + profile.getZenodoId()
+ "\", \"expirationDate\": \"" + Instant.now().plusSeconds(profile.getZenodoExpire()).toEpochMilli()
+ "\"},\"zenodoToken\":\"" + profile.getZenodoId()
+ "\", \"expirationDate\": \"" + Instant.now().plusSeconds((profile.getZenodoExpire() != null ? profile.getZenodoExpire(): 0)).toEpochMilli()
+ "\", \"zenodoRefresh\": \"" + profile.getZenodoRefresh()
+ (profile.getProvider() == TokenValidatorFactoryImpl.LoginProvider.ZENODO ? "\", \"zenodoEmail\": \"" + profile.getEmail() : "") +"\"}")
+ (profile.getProvider() == TokenValidatorFactoryImpl.LoginProvider.ZENODO ? "\", \"zenodoEmail\": \"" + profile.getEmail() : "") +"\"}}")
.authorization_level((short) 1).usertype((short) 1)
.build();

View File

@ -68,18 +68,22 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
this.id = entity.getId().toString();
this.name = entity.getLabel();
this.label = entity.getUri();
this.reference = entity.getReference();
this.key = entity.getReference().substring(0, entity.getReference().indexOf(":"));
if (entity.getReference() != null) {
this.reference = entity.getReference();
this.key = entity.getReference().substring(0, entity.getReference().indexOf(":"));
}
return this;
}
@Override
public eu.eudat.data.entities.Organisation toDataModel() {
eu.eudat.data.entities.Organisation organisationEntity = new eu.eudat.data.entities.Organisation();
if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
organisationEntity.setReference(this.reference);
} else {
organisationEntity.setReference(this.key + ":" + this.reference);
if (this.key != null && this.reference != null) {
if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
organisationEntity.setReference(this.reference);
} else {
organisationEntity.setReference(this.key + ":" + this.reference);
}
}
organisationEntity.setLabel(this.name);
organisationEntity.setUri(this.label);

View File

@ -164,7 +164,9 @@ public class Project implements DataModel<eu.eudat.data.entities.Project, Projec
this.abbreviation = entity.getAbbreviation();
this.reference = entity.getReference();
this.uri = entity.getUri();
this.type = entity.getType();
if (entity.getType() != null) {
this.type = entity.getType();
}
this.definition = entity.getDefinition();
this.startDate = entity.getStartdate();
this.endDate = entity.getEnddate();

View File

@ -77,4 +77,7 @@ zenodo.login.redirect_uri=http://localhost:4200/login/external/zenodo
#############CONTACT EMAIL CONFIGURATIONS#########
contact_email.mail=
language.path=tempLang/i18n/
language.path=i18n/
#############LOGGING#########
logging.config=classpath:logging/logback-${spring.profiles.active}.xml

View File

@ -1,9 +1,9 @@
dmp.domain = https://devel.opendmp.eu
####################PERSISTENCE OVERRIDES CONFIGURATIONS##########
database.url=
database.username=
database.password=
database.url=jdbc:postgresql://dmp-db:5432/dmptool
database.username=dmptool
database.password=CHANGEME
####################ELASTIIC SEARCH TAGS OVERRIDES CONFIGURATIONS##########
elasticsearch.host = tags-elastic-search
@ -18,10 +18,10 @@ http-logger.server-address = http://logstash:31311
pdf.converter.url=http://docsbox-web/
####################CONFIGURATION FILES OVERRIDES CONFIGURATIONS##########
configuration.externalUrls=/tmp/ExternalUrls.xml
configuration.externalUrls=externalUrls/ExternalUrls.xml
configuration.rda=/tmp/RDACommonStandards.txt
configuration.h2020template=tmp/h2020.docx
configuration.configurable_login_providers=
configuration.h2020template=documents/h2020.docx
configuration.configurable_login_providers=/tmp/ConfigurableLoginProviders.json
####################INVITATION MAIL CONFIGURATIONS##############
####################GENERIC MAIL CONFIGURATIONS#################
@ -86,4 +86,6 @@ zenodo.url=https://sandbox.zenodo.org/api/
zenodo.access_token=
#############CONTACT EMAIL CONFIGURATIONS#########
contact_email.mail=
contact_email.mail=
language.path=i18n/

View File

@ -1,8 +1,8 @@
server.port=8080
server.port=8081
server.tomcat.max-threads = 20
server.tomcat.max-connections = 10000
logging.file=/logs/spring-boot-logging.log
spring.profiles.active=devel
spring.profiles.active=staging
eu.eudat.logic.proxy.allowed.host=https://eestore.paas2.uninett.no
####################INVITATION MAIL CONFIGURATIONS##############
@ -79,7 +79,7 @@ database.lock-fail-interval=120000
##########################MISC##########################################
#############USER GUIDE#########
userguide.path=guide/
userguide.path=user-guide/
#############NOTIFICATION#########
notification.rateInterval=30000
@ -90,7 +90,7 @@ notification.finalised.subject=[OpenDMP] The {name} has been finalised
notification.modifiedFinalised.subject=[OpenDMP] The {name} has been modified and finalised
#############LOGGING#########
logging.config=classpath:logging/logback-${spring.profiles.active}.xml
logging.config=file:/app/logging/logback-${spring.profiles.active}.xml
#############TEMP#########
temp.temp=tmp/

View File

@ -7,9 +7,9 @@
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/files/logs/openDMP.log</file>
<file>/app/logs/openDMP.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/files/logs/openDMP-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<fileNamePattern>/app/logs/openDMP-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>

View File

@ -7,9 +7,9 @@
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/files/logs/openDMP.log</file>
<file>/app/logs/openDMP.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/files/logs/openDMP-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<fileNamePattern>/app/logs/openDMP-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>

View File

@ -0,0 +1,5 @@
ADMIN_USERNAME=admin
ADMIN_PASSWORD=CHANGEME
POSTGRES_DB=dmptool
POSTGRES_USER=dmptool
POSTGRES_PASSWORD=CHANGEME

7
dmp-db-scema/initdb.sh Normal file
View File

@ -0,0 +1,7 @@
psql -d dmptool -U dmptool -f main/DataManagementPlanDB.sql;
for j in $(ls updates); do
for i in $(ls updates/$j/*.sql); do
echo $i
psql --set=ADMIN_USERNAME="$ADMIN_USERNAME" --set=ADMIN_PASSWORD="$ADMIN_PASSWORD" -d dmptool -U dmptool -f $i;
done
done

View File

@ -34,7 +34,7 @@ DROP table if exists "UserAuth" cascade;
-- CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
-- CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
SET search_path = public, pg_catalog;
@ -550,8 +550,8 @@ ALTER TABLE "UserDMP" OWNER TO dmptool;
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
-- REVOKE ALL ON SCHEMA public FROM postgres;
-- GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;

View File

@ -1,12 +1,12 @@
INSERT INTO public."UserDMP"(
usr, dmp, role)
SELECT "Creator", "ID", 0
FROM public."DMP"
FROM public."DMP";
DELETE
FROM public."UserDMP" as us1
using public."UserDMP" as us2
where us1."id" < us2."id" AND us1."dmp" = us2."dmp"
where us1."id" < us2."id" AND us1."dmp" = us2."dmp";
@ -31,30 +31,31 @@ WITH (
TABLESPACE pg_default;
ALTER TABLE public."DMPDatasetProfile"
OWNER to dmtadm;
-- OWNER to dmtadm;
OWNER to dmptool;
ALTER TABLE public."UserDMP"
OWNER to dmtadm;
-- OWNER to dmtadm;
OWNER to dmptool;
INSERT INTO public."DMPDatasetProfile"(
dmp, datasetprofile)
SELECT "ID", unnest(xpath('/profiles/profile/@profileId', dmpp."AssociatedDmps"::xml)::text[]::UUID[])
FROM public."DMP" as dmpp
--INSERT INTO public."DMPDatasetProfile"(
-- dmp, datasetprofile)
-- SELECT "ID", unnest(xpath('/profiles/profile/@profileId', dmpp."AssociatedDmps"::xml)::text[]::UUID[])
-- FROM public."DMP" as dmpp;
Alter table public."DMP"
add "FinalizedDat" timestamp(6) with time zone
ALTER TABLE public."DMP"
ADD "FinalizedDat" timestamp(6) WITH time zone;
update public."DMP" SET "FinalizedDat" = "Modified"
where "Status" = 1
UPDATE public."DMP" SET "FinalizedDat" = "Modified"
WHERE "Status" = 1;
Alter table public."Dataset"
add "FinalizedDat" timestamp(6) with time zone
ALTER TABLE public."Dataset"
ADD "FinalizedDat" timestamp(6) WITH time zone;
update public."Dataset" SET "FinalizedDat" = "Modified"
where "Status" = 1
UPDATE public."Dataset" SET "FinalizedDat" = "Modified"
WHERE "Status" = 1;

View File

@ -3,5 +3,5 @@ Add "isPublic" boolean NOT NULL Default False;
UPDATE public."DMP"
SET "isPublic" = True
WHERE "Status" = 1
WHERE "Status" = 1;

View File

@ -1,6 +1,6 @@
ALTER TABLE public."DMP"
ADD "PublishedAt" timestamp(6) with time zone
ADD "PublishedAt" timestamp(6) WITH time zone;
UPDATE public."DMP"
SET "PublishedAt" = "FinalizedDat"
where "isPublic" = True
where "isPublic" = True;

View File

@ -1,2 +1,2 @@
ALTER TABLE public."DMP"
ADD COLUMN "DOI" text
ADD COLUMN "DOI" text;

View File

@ -0,0 +1,15 @@
CREATE TABLE public."Content" (
"Id" uuid NOT NULL,
"Filename" character varying NOT NULL,
"Extension" character varying NOT NULL,
"ParentType" numeric NOT NULL,
"Uri" character varying NOT NULL,
"LocationType" numeric NOT NULL
);
ALTER TABLE public."Content" OWNER TO dmptool;
ALTER TABLE ONLY public."Content"
ADD CONSTRAINT "Content_pkey" PRIMARY KEY ("Id");

View File

@ -1,2 +0,0 @@
ALTER TABLE public."Dataset"
DROP COLUMN "IsPublic"

View File

@ -14,4 +14,5 @@ WITH (
TABLESPACE pg_default;
ALTER TABLE public."LoginConfirmationEmail"
OWNER to dmtadm;
-- OWNER to dmtadm;
OWNER to dmptool;

View File

@ -0,0 +1,9 @@
ALTER TABLE public."Grant"
ADD COLUMN "Content" uuid;
ALTER TABLE public."Grant"
ADD CONSTRAINT fk_grant_content FOREIGN KEY ("Content")
REFERENCES public."Content" ("Id") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION;

View File

@ -1,2 +0,0 @@
ALTER TABLE public."Grant"
RENAME CONSTRAINT "fk_project_content" TO "fk_grant_content";

View File

@ -0,0 +1,18 @@
ALTER TABLE public."Grant"
ALTER COLUMN "Reference" TYPE character varying(255);
ALTER TABLE public."Grant"
ALTER COLUMN "Definition" TYPE character varying;
ALTER TABLE public."Registry"
ALTER COLUMN "Reference" TYPE character varying;
ALTER TABLE public."Service"
ALTER COLUMN "Reference" TYPE character varying;
ALTER TABLE public."Researcher"
ALTER COLUMN "Reference" TYPE character varying;
ALTER TABLE public."DataRepository"
ALTER COLUMN "Reference" TYPE character varying;

View File

@ -0,0 +1,2 @@
ALTER TABLE "Funder"
ADD COLUMN "CreationUser" uuid;

View File

@ -1,4 +1,4 @@
Update "Funder" as funder
set "CreationUser" = grant1."CreationUser"
from "Grant" as grant1
where funder."ID" = grant1."Funder"
where funder."ID" = grant1."Funder" ;

View File

@ -0,0 +1,15 @@
CREATE TABLE public."ExternalDataset" (
"Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
"Label" character varying NOT NULL,
"Abbreviation" character varying,
"Reference" character varying NOT NULL,
"Created" timestamp(4) with time zone NOT NULL,
"Modified" timestamp(4) with time zone NOT NULL
);
ALTER TABLE public."ExternalDataset" OWNER TO dmptool;
ALTER TABLE ONLY public."ExternalDataset"
ADD CONSTRAINT "ExternalDataset_pkey" PRIMARY KEY ("Id");

View File

@ -0,0 +1,11 @@
ALTER TABLE "DataRepository"
ADD COLUMN "CreationUser" uuid;
ALTER TABLE "ExternalDataset"
ADD COLUMN "CreationUser" uuid;
ALTER TABLE "Registry"
ADD COLUMN "CreationUser" uuid;
ALTER TABLE "Service"
ADD COLUMN "CreationUser" uuid;

View File

@ -0,0 +1,2 @@
ALTER TABLE "Researcher"
ADD COLUMN "CreationUser" uuid;

View File

@ -1,11 +0,0 @@
ALTER TABLE "DataRepository"
ADD COLUMN "CreationUser" uuid
ALTER TABLE "ExternalDataset"
ADD COLUMN "CreationUser" uuid
ALTER TABLE "Registry"
ADD COLUMN "CreationUser" uuid
ALTER TABLE "Service"
ADD COLUMN "CreationUser" uuid

View File

@ -1,2 +0,0 @@
ALTER TABLE "Funder"
ADD COLUMN "CreationUser" uuid

View File

@ -1,2 +0,0 @@
ALTER TABLE "Researcher"
ADD COLUMN "CreationUser" uuid

View File

@ -1,6 +0,0 @@
UPDATE "Researcher"
SET "Reference" = CONCAT(LOWER(LEFT("Reference", 1)), SUBSTRING("Reference", 2))
WHERE "ID" in (
SELECT "ID" FROM "Researcher"
WHERE ASCII(LEFT("Reference", 1)) BETWEEN ASCII('A') AND ASCII('Z')
)

View File

@ -0,0 +1,23 @@
ALTER TABLE public."DMP"
ADD COLUMN "DmpProperties" text;
ALTER TABLE public."DMP"
ADD COLUMN "GroupId" uuid;
ALTER TABLE public."DMP"
ADD COLUMN "Properties" text;
ALTER TABLE public."DatasetProfile"
ADD COLUMN "GroupId" uuid;
ALTER TABLE public."DatasetProfile"
ADD COLUMN "Version" integer;
ALTER TABLE public."Grant"
ADD COLUMN "Type" numeric NOT NULL;
ALTER TABLE public."DatasetDataRepository"
ADD COLUMN "Data" character varying;
ALTER TABLE public."DatasetService"
ADD COLUMN "Data" character varying;

View File

@ -0,0 +1,25 @@
CREATE TABLE public."Credential" (
"Id" uuid NOT NULL,
"Status" numeric NOT NULL,
"Provider" numeric NOT NULL,
"Public" character varying NOT NULL,
"Secret" character varying NOT NULL,
"CreationTime" timestamp(4) with time zone NOT NULL,
"LastUpdateTime" timestamp(4) with time zone NOT NULL,
"UserId" uuid NOT NULL,
"ExternalId" character varying NOT NULL
);
ALTER TABLE public."Credential" OWNER TO dmptool;
ALTER TABLE ONLY public."Credential"
ADD CONSTRAINT "Credential_pkey" PRIMARY KEY ("Id");
ALTER TABLE ONLY public."Credential"
ADD CONSTRAINT fkey_credential_user FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);
INSERT INTO public."UserInfo"(email, authorization_level, usertype, name, created, additionalinfo) VALUES ('fake@email.org', 1, 1, :'ADMIN_USERNAME', now(), '{}');
INSERT INTO public."Credential" VALUES (uuid_generate_v4(), 0, 5, :'ADMIN_USERNAME', :'ADMIN_PASSWORD', now(), now(), (SELECT public."UserInfo"."id" FROM public."UserInfo" WHERE name = 'admin'), 'dmp');

View File

@ -0,0 +1,16 @@
CREATE TABLE public."UserToken" (
"Token" uuid NOT NULL,
"UserId" uuid NOT NULL,
"IssuedAt" timestamp(4) with time zone NOT NULL,
"ExpiresAt" timestamp(4) with time zone NOT NULL
);
ALTER TABLE public."UserToken" OWNER TO dmptool;
ALTER TABLE ONLY public."UserToken"
ADD CONSTRAINT "UserToken_pkey" PRIMARY KEY ("Token");
ALTER TABLE ONLY public."UserToken"
ADD CONSTRAINT fkey_usetoken_user FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);

View File

@ -0,0 +1,18 @@
CREATE TABLE public."UserRole" (
"Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
"Role" numeric DEFAULT 0 NOT NULL,
"UserId" uuid NOT NULL
);
ALTER TABLE public."UserRole" OWNER TO dmptool;
ALTER TABLE ONLY public."UserRole"
ADD CONSTRAINT "UserRole_pkey" PRIMARY KEY ("Id");
ALTER TABLE ONLY public."UserRole"
ADD CONSTRAINT "UserRole_userId_fkey" FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);
INSERT INTO public."UserRole"("Role", "UserId") VALUES (2, (SELECT public."UserInfo"."id" FROM public."UserInfo" WHERE name = 'admin'));

View File

@ -0,0 +1 @@
DROP TABLE IF EXISTS "UserAuth" CASCADE;

View File

@ -0,0 +1,2 @@
AlTER TABLE "DMP"
ALTER COLUMN "Creator" DROP NOT NULL;

View File

@ -0,0 +1,19 @@
CREATE TABLE public."DatasetExternalDataset" (
"Id" uuid DEFAULT public.uuid_generate_v4() NOT NULL,
"Dataset" uuid NOT NULL,
"ExternalDataset" uuid NOT NULL,
"Role" numeric,
"Data" character varying
);
ALTER TABLE public."DatasetExternalDataset" OWNER TO dmptool;
ALTER TABLE ONLY public."DatasetExternalDataset"
ADD CONSTRAINT "DatasetExternalDataset_pkey" PRIMARY KEY ("Id");
ALTER TABLE ONLY public."DatasetExternalDataset"
ADD CONSTRAINT fkey_datasetexternaldataset_dataset FOREIGN KEY ("Dataset") REFERENCES public."Dataset"("ID");
ALTER TABLE ONLY public."DatasetExternalDataset"
ADD CONSTRAINT fkey_datasetexternaldataset_externaldataset FOREIGN KEY ("ExternalDataset") REFERENCES public."ExternalDataset"("Id");

View File

@ -0,0 +1,23 @@
CREATE TABLE public."Invitation" (
"Id" uuid NOT NULL,
"InvitationEmail" character varying NOT NULL,
"Token" uuid NOT NULL,
"CreationUser" uuid NOT NULL,
"Dmp" uuid NOT NULL,
"Properties" xml,
"AcceptedInvitation" boolean
);
ALTER TABLE public."Invitation" OWNER TO dmptool;
ALTER TABLE ONLY public."Invitation"
ADD CONSTRAINT "Invitation_pkey" PRIMARY KEY ("Id");
ALTER TABLE ONLY public."Invitation"
ADD CONSTRAINT fk_invitation_creator FOREIGN KEY ("CreationUser") REFERENCES public."UserInfo"(id);
ALTER TABLE ONLY public."Invitation"
ADD CONSTRAINT fk_invitation_dmp FOREIGN KEY ("Dmp") REFERENCES public."DMP"("ID");

View File

@ -0,0 +1,16 @@
CREATE TABLE public."UserPreference" (
"Id" uuid NOT NULL,
"UserId" uuid NOT NULL,
"Data" json NOT NULL,
"PreferenceType" smallint NOT NULL
);
ALTER TABLE public."UserPreference" OWNER TO dmptool;
ALTER TABLE ONLY public."UserPreference"
ADD CONSTRAINT "UserPreference_pkey" PRIMARY KEY ("Id");
ALTER TABLE ONLY public."UserPreference"
ADD CONSTRAINT userpreference_user_fk FOREIGN KEY ("UserId") REFERENCES public."UserInfo"(id);

View File

@ -0,0 +1,21 @@
CREATE TABLE public."UserAssociation" (
id uuid NOT NULL,
"firstUser" uuid NOT NULL,
"secondUser" uuid NOT NULL
);
ALTER TABLE public."UserAssociation" OWNER TO dmptool;
ALTER TABLE ONLY public."UserAssociation"
ADD CONSTRAINT pk_user_association PRIMARY KEY (id);
ALTER TABLE ONLY public."UserAssociation"
ADD CONSTRAINT fk_userinfo_user_association_1 FOREIGN KEY ("firstUser") REFERENCES public."UserInfo"(id);
ALTER TABLE ONLY public."UserAssociation"
ADD CONSTRAINT fk_userinfo_user_association_2 FOREIGN KEY ("secondUser") REFERENCES public."UserInfo"(id);
INSERT INTO public."DBVersion" VALUES ('DMPDB', '00.00.002', '2020-05-04 13:42:00.000000+03', now(), 'Add User Association');

View File

@ -0,0 +1,24 @@
CREATE TABLE public."DoiFunder" (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying,
doi character varying
);
ALTER TABLE ONLY public."DoiFunder"
ADD CONSTRAINT "DoiFunder_pkey" PRIMARY KEY (id);
ALTER TABLE public."DoiFunder" OWNER TO dmptool;
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Australian Research Council', '10.13039/501100000923');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('European Commission', '10.13039/501100000780');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Fundação para a Ciência e a Tecnologia', '10.13039/501100001871');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Ministarstvo Prosvete, Nauke i Tehnološkog Razvoja', '10.13039/501100004564');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Ministarstvo Znanosti, Obrazovanja i Sporta', '10.13039/501100006588');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('National Health and Medical Research Council', '10.13039/501100000925');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('National Science Foundation','10.13039/100000001');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Nederlandse Organisatie voor Wetenschappelijk Onderzoek', '10.13039/501100003246');
INSERT INTO public."DoiFunder"(name, doi) VALUES ('Wellcome Trust', '10.13039/100004440');

View File

@ -1,17 +1,32 @@
FROM johnpapa/angular-cli as angular
WORKDIR /app
COPY package.json /app/
RUN npm cache clear --force && npm install
# stage1 as builder
FROM node:12-alpine as builder
COPY ./ /app/
ARG env=dev
ARG aot=--no-aot
RUN echo $env
RUN echo $aot
RUN if [ "$env" = "prod" ]; then ng build --$env --$aot; else ng build --$aot; fi
WORKDIR /page
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
FROM nginx:1.13
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 the package.json to install dependencies
COPY package.json /page
# Install the dependencies and make the folder
RUN npm install
COPY . /page
# Build the project and copy the files
RUN npm run ng build -- --deploy-url=/ --prod
FROM nginx:alpine
#!/bin/sh
COPY nginx.conf /etc/nginx
COPY mime.types /etc/nginx
## Remove default nginx index page
RUN rm -rf /usr/share/nginx/html/*
# Copy from the stahg 1
COPY --from=builder /page/dist /usr/share/nginx/html
EXPOSE 4200
ENTRYPOINT ["nginx", "-g", "daemon off;", "-p", "/usr/share/nginx"]

48
dmp-frontend/mime.types Normal file
View File

@ -0,0 +1,48 @@
types {
text/html html htm shtml;
text/css css;
text/xml xml rss;
image/gif gif;
image/jpeg jpeg jpg;
application/x-javascript js;
text/plain txt;
text/x-component htc;
text/mathml mml;
image/png png;
image/x-icon ico;
image/x-jng jng;
image/vnd.wap.wbmp wbmp;
application/java-archive jar war ear;
application/mac-binhex40 hqx;
application/pdf pdf;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/zip zip;
application/octet-stream deb;
application/octet-stream bin exe dll;
application/octet-stream dmg;
application/octet-stream eot;
application/octet-stream iso img;
application/octet-stream msi msp msm;
audio/mpeg mp3;
audio/x-realaudio ra;
video/mpeg mpeg mpg;
video/quicktime mov;
video/x-flv flv;
video/x-msvideo avi;
video/x-ms-wmv wmv;
video/x-ms-asf asx asf;
video/x-mng mng;
}

35
dmp-frontend/nginx.conf Normal file
View File

@ -0,0 +1,35 @@
events {
worker_connections 4096; ## Default: 1024
}
http {
include ./mime.types;
server {
listen 4200;
sendfile on;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 1100;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html =404;
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
}
}

View File

@ -1,4 +1,4 @@
import { Status } from "../../common/enum/Status";
import { Status } from "../../common/enum/status";
import { DmpProfile, DmpProfileDefinition } from "../dmp-profile/dmp-profile";
import { OrganizationModel } from "../organisation/organization";
import { GrantListingModel } from "../grant/grant-listing";

View File

@ -1,4 +1,4 @@
import { Status } from "../../common/enum/Status";
import { Status } from "../../common/enum/status";
export class FunderModel {
id: string;

View File

@ -1,6 +1,6 @@
import { UrlListingItem } from "../../../library/url-listing/url-listing-item";
import { GrantType } from '../../common/enum/grant-type';
import { Status } from '../../common/enum/Status';
import { Status } from '../../common/enum/status';
export interface GrantListingModel {
id?: string;

View File

@ -1,4 +1,4 @@
import { Status } from "../../common/enum/Status";
import { Status } from "../../common/enum/status";
export interface OrganizationModel {
id: string;

View File

@ -1,4 +1,4 @@
import { Status } from "../../common/enum/Status";
import { Status } from "../../common/enum/status";
import { UrlListingItem } from "../../../library/url-listing/url-listing-item";
import { ProjectType } from "../../common/enum/project-type";

View File

@ -5,7 +5,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
import { Router } from '@angular/router';
import { Credential } from '@app/core/model/auth/credential';
import { LoginInfo } from '@app/core/model/auth/login-info';
import { Principal } from '@app/core/model/auth/Principal';
import { Principal } from '@app/core/model/auth/principal';
import { ConfigurableProvider } from '@app/core/model/configurable-provider/configurableProvider';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { BaseService } from '@common/base/base.service';

View File

@ -57,6 +57,16 @@ export class ConfigurationService extends BaseComponent {
return this._guideAssets;
}
private _allowOrganizationCreator: boolean;
get allowOrganizationCreator():boolean {
return this._allowOrganizationCreator;
}
private _doiLink: string;
get doiLink(): string {
return this._doiLink;
}
public loadConfiguration(): Promise<any> {
return new Promise((r, e) => {
@ -92,6 +102,8 @@ export class ConfigurationService extends BaseComponent {
this._logging = Logging.parseValue(config.logging);
this._lockInterval = config.lockInterval;
this._guideAssets = config.guideAssets;
this._allowOrganizationCreator = config.allowOrganizationCreator;
this._doiLink = config.doiLink;
}
}

View File

@ -17,18 +17,18 @@ export class LockService {
}
checkLockStatus(id: string): Observable<boolean> {
return this.http.get(`${this.actionUrl}target/status/${id}`, {headers: this.headers});
return this.http.get(`${this.actionUrl}target/status/${id}`, { headers: this.headers });
}
unlockTarget(id: string): Observable<any> {
return this.http.delete(`${this.actionUrl}target/unlock/${id}`, {headers: this.headers});
return this.http.delete(`${this.actionUrl}target/unlock/${id}`, { headers: this.headers });
}
getSingle(id: string): Observable<LockModel> {
return this.http.get(`${this.actionUrl}target/${id}`, {headers: this.headers});
return this.http.get(`${this.actionUrl}target/${id}`, { headers: this.headers });
}
createOrUpdate(lock: LockModel): Observable<string> {
return this.http.post(`${this.actionUrl}`, lock, {headers: this.headers});
return this.http.post(`${this.actionUrl}`, lock, { headers: this.headers });
}
}

View File

@ -27,6 +27,7 @@ import { DialodConfirmationUploadDatasetProfiles } from '@app/ui/admin/dataset-p
import { DatasetProfileListingComponent } from '@app/ui/admin/dataset-profile/listing/dataset-profile-listing.component';
import { CommonFormsModule } from '@common/forms/common-forms.module';
import { CommonUiModule } from '@common/ui/common-ui.module';
import { ParseStatus } from './listing/pipe/parse-status.pipe';
@NgModule({
imports: [
@ -59,7 +60,8 @@ import { CommonUiModule } from '@common/ui/common-ui.module';
DatasetProfileEditorInternalDmpEntitiesFieldComponent,
DatasetProfileEditorResearchersAutoCompleteFieldComponent,
DatasetProfileEditorDatasetsAutoCompleteFieldComponent,
DatasetProfileEditorDmpsAutoCompleteFieldComponent
DatasetProfileEditorDmpsAutoCompleteFieldComponent,
ParseStatus
],
entryComponents: [
DialodConfirmationUploadDatasetProfiles

View File

@ -5,6 +5,13 @@
<input matInput placeholder=" {{'CRITERIA.DATASET-PROFILE.LIKE'| translate}}" name="datasetProfileLike"
[(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
</mat-form-field>
<mat-form-field class="col-md-6">
<mat-select [(ngModel)]="criteria.status" (ngModelChange)="controlModified()" placeholder=" {{'CRITERIA.DATASET-PROFILE.STATUS' | translate}}">
<mat-option [value]="null">{{'DATASET-PROFILE-STATUS.NONE' | translate}}</mat-option>
<mat-option [value]="0">{{'DATASET-PROFILE-STATUS.DRAFT' | translate}}</mat-option>
<mat-option [value]="1">{{'DATASET-PROFILE-STATUS.FINALIZED' | translate}}</mat-option>
</mat-select>
</mat-form-field>
<div class="col"></div>
<div class="col-auto">
<!-- imgFileInput.click() && -->

View File

@ -27,6 +27,13 @@
<mat-cell *matCellDef="let row">{{row.created | date:'shortDate'}}</mat-cell>
</ng-container>
<!-- Column Definition: Status -->
<ng-container cdkColumnDef="status">
<mat-header-cell *matHeaderCellDef mat-sort-header="status">{{'DATASET-PROFILE-LISTING.COLUMNS.STATUS' |
translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{ (row.status | parseStatus) | translate}}</mat-cell>
</ng-container>
<!-- Column Definition: Submission Time -->
<ng-container cdkColumnDef="actions">
<mat-header-cell *matHeaderCellDef>{{'DATASET-PROFILE-LISTING.COLUMNS.ACTIONS' | translate}}

View File

@ -30,7 +30,7 @@ export class DatasetProfileListingComponent extends BaseComponent implements OnI
breadCrumbs: Observable<BreadcrumbItem[]>;
dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'description', 'created', 'actions'];
displayedColumns: String[] = ['label', 'description', 'created', 'status', 'actions'];
pageEvent: PageEvent;
titlePrefix: String;
dmpId: String;

View File

@ -0,0 +1,16 @@
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'parseStatus',
pure: true
})
export class ParseStatus implements PipeTransform {
transform(value: any, ...args: any[]) {
return this.parseStatus(value);
}
parseStatus(status: number): string {
return status != 0 ? 'DATASET-PROFILE-STATUS.FINALIZED' : 'DATASET-PROFILE-STATUS.DRAFT';
}
}

View File

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { MatDialog } from '@angular/material';
import { Router } from '@angular/router';
import { RecentActivityType } from '@app/core/common/enum/recent-activity-type';
import { Principal } from '@app/core/model/auth/Principal';
import { Principal } from '@app/core/model/auth/principal';
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
import { DmpListingModel } from '@app/core/model/dmp/dmp-listing';
import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria';
@ -10,7 +10,7 @@ import { AuthService } from '@app/core/services/auth/auth.service';
import { DmpService } from '@app/core/services/dmp/dmp.service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component';
import { BaseComponent } from '@common/base/base.component';
import { TranslateService } from '@ngx-translate/core';
import * as FileSaver from 'file-saver';

View File

@ -31,6 +31,7 @@ import { CommonFormsModule } from '@common/forms/common-forms.module';
import { FormValidationErrorsDialogModule } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.module';
import { CommonUiModule } from '@common/ui/common-ui.module';
import { MultipleChoiceDialogModule } from '@common/modules/multiple-choice-dialog/multiple-choice-dialog.module';
import { AddOrganizationComponent } from './editor/add-organization/add-organization.component';
@NgModule({
imports: [
@ -67,14 +68,16 @@ import { MultipleChoiceDialogModule } from '@common/modules/multiple-choice-dial
PeopleTabComponent,
GrantTabComponent,
DatasetsTabComponent,
DmpCloneComponent
DmpCloneComponent,
AddOrganizationComponent
],
entryComponents: [
DmpInvitationDialogComponent,
AddResearcherComponent,
AvailableProfilesComponent,
DmpFinalizeDialogComponent,
DmpUploadDialogue
DmpUploadDialogue,
AddOrganizationComponent
]
})
export class DmpModule { }

View File

@ -0,0 +1,19 @@
<form *ngIf="formGroup" [formGroup]="formGroup">
<h1 mat-dialog-title>{{'ADDORGANIZATION-EDITOR.TITLE' | translate}}</h1>
<div mat-dialog-content class="row">
<mat-form-field class="col-12">
<input matInput formControlName="name" placeholder="{{'ADDORGANIZATION-EDITOR.NAME' | translate}}" required>
<mat-error *ngIf="formGroup.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<!-- <mat-form-field class="col-12">
<input matInput formControlName="lastName" placeholder="{{'ADDORGANIZATION-EDITOR.LAST_NAME' | translate}}" required>
<mat-error *ngIf="formGroup.get('lastName').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> -->
<div class="col-12">
<div class="row">
<div class="ml-auto col-auto"><button mat-raised-button mat-dialog-close type="button">{{'ADDORGANIZATION-EDITOR.ACTIONS.CANCEL' | translate}}</button></div>
<div class="col-auto"><button mat-raised-button [disabled]="!isFormValid()" color="primary" (click)="addOrganization()" type="button">{{'ADDORGANIZATION-EDITOR.ACTIONS.SAVE' | translate}}</button></div>
</div>
</div>
</div>
</form>

View File

@ -0,0 +1,43 @@
import { Component, Inject, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { ExternalResearcherService } from '@app/core/services/external-sources/researcher/external-researcher.service';
import { BaseComponent } from '@common/base/base.component';
import { takeUntil } from 'rxjs/operators';
import { OrganizationEditorModel } from './add-organization.model';
@Component({
selector: 'app-add-organization-component',
templateUrl: 'add-organization.component.html',
})
export class AddOrganizationComponent extends BaseComponent implements OnInit {
public formGroup: FormGroup;
constructor(
private externalResearcherService: ExternalResearcherService,
public dialogRef: MatDialogRef<AddOrganizationComponent>,
@Inject(MAT_DIALOG_DATA) public data: any
) { super(); }
ngOnInit(): void {
const researcher = new OrganizationEditorModel();
this.formGroup = researcher.buildForm();
}
send(value: any) {
this.externalResearcherService.createResearcher(this.formGroup.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
null, null, () => this.dialogRef.close()
);
}
addOrganization() {
this.dialogRef.close(this.formGroup.value);
}
isFormValid() {
return this.formGroup.valid;
}
}

View File

@ -0,0 +1,33 @@
import { FormBuilder, FormGroup } from '@angular/forms';
import { ResearcherModel } from '@app/core/model/researcher/researcher';
import { BackendErrorValidator } from '@common/forms/validation/custom-validator';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { ValidationContext } from '@common/forms/validation/validation-context';
import { OrganizationModel } from '@app/core/model/organisation/organization';
export class OrganizationEditorModel {
public id: String;
public name: String;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
fromModel(item: OrganizationModel): OrganizationEditorModel {
this.id = item.id;
this.name = item.name;
return this;
}
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({
name: [{ value: this.name, disabled: disabled }, context.getValidation('name').validators]
});
return formGroup;
}
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'name', validators: [BackendErrorValidator(this.validationErrorModel, 'name')] });
return baseContext;
}
}

View File

@ -34,7 +34,7 @@ import { TranslateService } from '@ngx-translate/core';
import * as FileSaver from 'file-saver';
import { Observable, of as observableOf, interval } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { Principal } from "@app/core/model/auth/Principal";
import { Principal } from "@app/core/model/auth/principal";
import { Role } from "@app/core/common/enum/role";
import { LockService } from '@app/core/services/lock/lock.service';
import { Location } from '@angular/common';
@ -109,7 +109,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
// displayFn: (item) => item['label'],
// titleFn: (item) => item['label']
// };
switch(tabToNav) {
switch (tabToNav) {
case 'general':
this.selectedTab = 0;
break;
@ -130,52 +130,52 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
.subscribe(async data => {
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.dmp = new DmpEditorModel();
this.dmp.grant = new GrantTabModel();
this.dmp.project = new ProjectFormModel();
this.dmp.funder = new FunderFormModel();
this.dmp.fromModel(data);
this.formGroup = this.dmp.buildForm();
this.setIsUserOwner();
if (!this.isUserOwner) {
this.isFinalized = true;
this.formGroup.disable();
}
this.dmp = new DmpEditorModel();
this.dmp.grant = new GrantTabModel();
this.dmp.project = new ProjectFormModel();
this.dmp.funder = new FunderFormModel();
this.dmp.fromModel(data);
this.formGroup = this.dmp.buildForm();
this.setIsUserOwner();
if (!this.isUserOwner) {
this.isFinalized = true;
this.formGroup.disable();
}
//this.registerFormEventsForDmpProfile(this.dmp.definition);
if (!this.editMode || this.dmp.status === DmpStatus.Finalized || lockStatus) {
this.isFinalized = true;
this.formGroup.disable();
}
//this.registerFormEventsForDmpProfile(this.dmp.definition);
if (!this.editMode || this.dmp.status === DmpStatus.Finalized || lockStatus) {
this.isFinalized = true;
this.formGroup.disable();
}
if (this.isAuthenticated) {
if (!lockStatus) {
this.lock = new LockModel(data.id, this.getUserFromDMP());
if (this.isAuthenticated) {
if (!lockStatus) {
this.lock = new LockModel(data.id, this.getUserFromDMP());
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
});
}
// if (!this.isAuthenticated) {
const breadCrumbs = [];
breadCrumbs.push({
parentComponentName: null,
label: this.language.instant('NAV-BAR.MY-DMPS'),
url: "/plans"
});
breadCrumbs.push({
parentComponentName: 'DmpListingComponent',
label: this.dmp.label,
url: '/plans/edit/' + this.dmp.id,
// notFoundResolver: [await this.grantService.getSingle(this.dmp.grant.id).map(x => ({ label: x.label, url: '/grants/edit/' + x.id }) as BreadcrumbItem).toPromise()]
}
);
this.breadCrumbs = observableOf(breadCrumbs);
}
// if (!this.isAuthenticated) {
const breadCrumbs = [];
breadCrumbs.push({
parentComponentName: null,
label: this.language.instant('NAV-BAR.MY-DMPS'),
url: "/plans"
});
breadCrumbs.push({
parentComponentName: 'DmpListingComponent',
label: this.dmp.label,
url: '/plans/edit/' + this.dmp.id,
// notFoundResolver: [await this.grantService.getSingle(this.dmp.grant.id).map(x => ({ label: x.label, url: '/grants/edit/' + x.id }) as BreadcrumbItem).toPromise()]
}
);
this.breadCrumbs = observableOf(breadCrumbs);
}
this.associatedUsers = data.associatedUsers;
this.people = data.users;
})
this.associatedUsers = data.associatedUsers;
this.people = data.users;
})
});
} else if (publicId != null) {
this.isNew = false;
@ -567,7 +567,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
private pumpLock() {
this.lock.touchedAt = new Date();
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe( async result => this.lock.id = Guid.parse(result));
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => this.lock.id = Guid.parse(result));
}
// advancedClicked() {

View File

@ -46,6 +46,9 @@
<mat-error *ngIf="formGroup.get('organisations').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
translate}}</mat-error>
<mat-hint>{{'DMP-EDITOR.FIELDS.ORGANISATIONS-HINT' | translate}}</mat-hint>
<button *ngIf="showOrganizationCreator()" matSuffix class="input-btn" [disabled]="canAddOrganizations()" type="button" (click)="addOrganization($event)">
<mat-icon class="icon-btn">add_circle</mat-icon>
</button>
</mat-form-field>
</div>
<div class="row pt-3">

View File

@ -20,6 +20,9 @@ import { BaseComponent } from '@common/base/base.component';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { AddOrganizationComponent } from '../add-organization/add-organization.component';
import { isNullOrUndefined } from 'util';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({
selector: 'app-general-tab',
@ -69,7 +72,8 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
private externalSourcesService: ExternalSourcesService,
private _service: DmpService,
private dialog: MatDialog,
private language: TranslateService
private language: TranslateService,
private configurationService: ConfigurationService
) {
super();
}
@ -170,6 +174,40 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
});
}
addOrganization(event: MouseEvent) {
event.stopPropagation();
const dialogRef = this.dialog.open(AddOrganizationComponent, {
data: this.formGroup.get('organisations')
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
const fullName = result.name;
const newItem = {
label: null,
name: fullName,
id: null,
status: 0,
key: "Internal",
};
const organizationsArray = this.formGroup.get('organisations').value || [];
organizationsArray.push(newItem);
this.formGroup.get('organisations').setValue(organizationsArray);
}
});
}
showOrganizationCreator(): boolean {
return this.configurationService.allowOrganizationCreator;
}
canAddOrganizations(): boolean {
if (!isNullOrUndefined(this.formGroup.get('organizations'))) {
return this.formGroup.get('organiztions').disabled;
} else {
return false;
}
}
availableProfiles(event: MouseEvent) {
event.stopPropagation();
const dialogRef = this.dialog.open(AvailableProfilesComponent, {

View File

@ -1,5 +1,5 @@
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Status } from '@app/core/common/enum/Status';
import { Status } from '@app/core/common/enum/status';
import { FunderModel } from '@app/core/model/funder/funder';
import { BackendErrorValidator } from '@common/forms/validation/custom-validator';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';

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