Merge branch 'dmp-refactoring' of code-repo.d4science.org:MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
91f7dbd785
|
@ -29,6 +29,9 @@ public class ReferenceType {
|
|||
private Instant updatedAt;
|
||||
public static final String _updatedAt = "updatedAt";
|
||||
|
||||
public final static String _hash = "hash";
|
||||
private String hash;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -84,4 +87,12 @@ public class ReferenceType {
|
|||
public void setUpdatedAt(Instant updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,11 @@ package eu.eudat.model.builder;
|
|||
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.XmlHandlingService;
|
||||
import eu.eudat.commons.types.reference.DefinitionEntity;
|
||||
import eu.eudat.commons.types.referencetype.ReferenceTypeDefinitionEntity;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.builder.referencedefinition.DefinitionBuilder;
|
||||
import eu.eudat.model.builder.referencetypedefinition.ReferenceTypeDefinitionBuilder;
|
||||
import eu.eudat.model.referencetypedefinition.ReferenceTypeDefinition;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.query.QueryFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
|
@ -66,6 +63,7 @@ public class ReferenceTypeBuilder extends BaseBuilder<ReferenceType, ReferenceTy
|
|||
if (fields.hasField(this.asIndexer(ReferenceType._createdAt))) m.setCreatedAt(d.getCreatedAt());
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._isActive))) m.setIsActive(d.getIsActive());
|
||||
if (fields.hasField(this.asIndexer(ReferenceType._hash))) m.setHash(this.hashValue(d.getUpdatedAt()));
|
||||
if (!definitionFields.isEmpty() && d.getDefinition() != null){
|
||||
ReferenceTypeDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, d.getDefinition());
|
||||
m.setDefinition(this.builderFactory.builder(ReferenceTypeDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition));
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.commons.enums.ReferenceTypeSourceType;
|
|||
import eu.eudat.commons.types.referencetype.*;
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.ReferenceTypeEntity;
|
||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||
import eu.eudat.model.ReferenceType;
|
||||
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||
import eu.eudat.model.deleter.ReferenceTypeDeleter;
|
||||
|
@ -53,12 +54,13 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
private final MessageSource messageSource;
|
||||
private final QueryFactory queryFactory;
|
||||
private final XmlHandlingService xmlHandlingService;
|
||||
private final ErrorThesaurusProperties errors;
|
||||
|
||||
|
||||
public ReferenceTypeServiceImpl(
|
||||
EntityManager entityManager, AuthorizationService authorizationService, DeleterFactory deleterFactory, BuilderFactory builderFactory,
|
||||
ConventionService conventionService, MessageSource messageSource, QueryFactory queryFactory,
|
||||
XmlHandlingService xmlHandlingService) {
|
||||
XmlHandlingService xmlHandlingService, ErrorThesaurusProperties errors) {
|
||||
this.entityManager = entityManager;
|
||||
this.authorizationService = authorizationService;
|
||||
this.deleterFactory = deleterFactory;
|
||||
|
@ -67,6 +69,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
this.messageSource = messageSource;
|
||||
this.queryFactory = queryFactory;
|
||||
this.xmlHandlingService = xmlHandlingService;
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,6 +85,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
|||
data = this.entityManager.find(ReferenceTypeEntity.class, model.getId());
|
||||
if (data == null)
|
||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||
} else {
|
||||
|
||||
data = new ReferenceTypeEntity();
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
artifactId=core
|
||||
groupId=eu.eudat
|
||||
version=1.0.0-SNAPSHOT
|
|
@ -292,12 +292,12 @@ public class ReferenceService {
|
|||
return null;
|
||||
}
|
||||
ReferenceTypeDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(ReferenceTypeDefinitionEntity.class, datas.get(0).getDefinition());
|
||||
List<Map<String, String>> remoteRepos = this.getAll(definition.getSources());
|
||||
List<Map<String, String>> remoteRepos = this.getAll(definition.getSources(), lookup);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Map<String, String>> getAll ( List<ReferenceTypeSourceBaseConfigurationEntity> sources){
|
||||
private List<Map<String, String>> getAll ( List<ReferenceTypeSourceBaseConfigurationEntity> sources, ReferenceDefinitionSearchLookup lookup){
|
||||
List<Map<String, String>> results = new LinkedList<>();
|
||||
|
||||
if (sources == null || sources.isEmpty()) {
|
||||
|
@ -305,19 +305,29 @@ public class ReferenceService {
|
|||
}
|
||||
|
||||
sources.sort(Comparator.comparing(ReferenceTypeSourceBaseConfigurationEntity::getOrdinal));
|
||||
List<ReferenceTypeSourceExternalApiConfigurationEntity> apiSources = sources.stream().filter(x-> ReferenceTypeSourceType.API.equals(x.getType())).map(x-> (ReferenceTypeSourceExternalApiConfigurationEntity)x).toList();
|
||||
|
||||
List<ReferenceTypeSourceExternalApiConfigurationEntity> apiSources = sources.stream().filter(x-> ReferenceTypeSourceType.API.equals(x.getType())).map(x-> (ReferenceTypeSourceExternalApiConfigurationEntity)x).toList();
|
||||
apiSources.forEach(source -> {
|
||||
try {
|
||||
String auth = null;
|
||||
if (source.getAuth()!= null) {
|
||||
//auth = this.getAuthentication(source.getAuth());
|
||||
}
|
||||
results.addAll(getAllResultsFromUrl(source.getUrl(), null, source.getResults(), source.getPaginationPath(), null, source.getLabel(), source.getKey(), source.getContentType(), source.getFirstPage(), source.getRequestBody(), source.getHttpMethod(), source.getFilterType(), source.getQueries(), auth));
|
||||
results.addAll(getAllApiResultsFromUrl(source.getUrl(), null, source.getResults(), source.getPaginationPath(), lookup, source.getLabel(), source.getKey(), source.getContentType(), source.getFirstPage(), source.getRequestBody(), source.getHttpMethod(), source.getFilterType(), source.getQueries(), auth));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
});
|
||||
List<ReferenceTypeSourceStaticOptionConfigurationEntity> staticSources = sources.stream().filter(x-> ReferenceTypeSourceType.STATIC.equals(x.getType())).map(x-> (ReferenceTypeSourceStaticOptionConfigurationEntity)x).toList();
|
||||
staticSources.forEach(source -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
source.getOptions().forEach(option -> {
|
||||
map.put(option.getCode(), option.getValue());
|
||||
map.put("label", source.getLabel());
|
||||
map.put("key", source.getKey());
|
||||
});
|
||||
results.add(map);
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
|
@ -349,23 +359,21 @@ public class ReferenceService {
|
|||
return finalBodyString;
|
||||
}
|
||||
|
||||
private List<Map<String, String>> getAllResultsFromUrl(String urlPath, FetchStrategy fetchStrategy, final ResultsConfigurationEntity jsonResultsPath, final String jsonPaginationPath, ExternalUrlCriteria externalUrlCriteria, String tag, String key, String contentType, String firstPage, String requestBody, ReferenceTypeExternalApiHTTPMethodType requestType, String filterType, List<QueryConfigEntity> queries, String auth) throws Exception {
|
||||
private List<Map<String, String>> getAllApiResultsFromUrl(String urlPath, FetchStrategy fetchStrategy, final ResultsConfigurationEntity resultsEntity, final String jsonPaginationPath, ReferenceDefinitionSearchLookup lookup, String label, String key, String contentType, String firstPage, String requestBody, ReferenceTypeExternalApiHTTPMethodType requestType, String filterType, List<QueryConfigEntity> queries, String auth) throws Exception {
|
||||
Set<Integer> pages = new HashSet<>();
|
||||
|
||||
//String replacedPath = replaceCriteriaOnUrl(urlPath, externalUrlCriteria, firstPage, queries);
|
||||
String replacedUrlPath = urlPath;
|
||||
//String replacedBody = replaceCriteriaOnUrl(requestBody, externalUrlCriteria, firstPage, queries);
|
||||
String replacedUrlBody = requestBody;
|
||||
String replacedUrlPath = replaceLookupFields(urlPath, lookup, firstPage, queries);
|
||||
String replacedUrlBody = replaceLookupFields(requestBody, lookup, firstPage, queries);
|
||||
|
||||
Results results = getResultsFromUrl(replacedUrlPath, jsonResultsPath, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth);
|
||||
Results results = getResultsFromUrl(replacedUrlPath, resultsEntity, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth);
|
||||
if(results != null) {
|
||||
if (filterType != null && filterType.equals("local") && (externalUrlCriteria.getLike() != null && !externalUrlCriteria.getLike().isEmpty())) {
|
||||
if (filterType != null && filterType.equals("local") && (lookup.getLike() != null && !lookup.getLike().isEmpty())) {
|
||||
results.setResults(results.getResults().stream()
|
||||
.filter(r -> r.get("name").toLowerCase().contains(externalUrlCriteria.getLike().toLowerCase()))
|
||||
.filter(r -> r.get("name").toLowerCase().contains(lookup.getLike().toLowerCase()))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
if (fetchStrategy == FetchStrategy.FIRST)
|
||||
return results.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||
return results.getResults().stream().peek(x -> x.put("label", label)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||
|
||||
if (results.getPagination() != null && results.getPagination().get("pages") != null) //if has more pages, add them to the pages set
|
||||
for (int i = 2; i <= results.getPagination().get("pages"); i++)
|
||||
|
@ -374,10 +382,10 @@ public class ReferenceService {
|
|||
//Long maxResults = configLoader.getExternalUrls().getMaxresults();
|
||||
Long maxResults = Long.valueOf(1000);
|
||||
if ((maxResults > 0) && (results.getPagination().get("count") > maxResults))
|
||||
throw new HugeResultSet("The submitted search query " + externalUrlCriteria.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
||||
throw new HugeResultSet("The submitted search query " + lookup.getLike() + " is about to return " + results.getPagination().get("count") + " results... Please submit a more detailed search query");
|
||||
|
||||
Optional<Results> optionalResults = pages.parallelStream()
|
||||
.map(page -> getResultsFromUrl(urlPath + "&page=" + page, jsonResultsPath, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth))
|
||||
.map(page -> getResultsFromUrl(urlPath + "&page=" + page, resultsEntity, jsonPaginationPath, contentType, replacedUrlBody, requestType, auth))
|
||||
.filter(Objects::nonNull)
|
||||
.reduce((result1, result2) -> {
|
||||
result1.getResults().addAll(result2.getResults());
|
||||
|
@ -386,14 +394,52 @@ public class ReferenceService {
|
|||
Results remainingResults = optionalResults.orElseGet(Results::new);
|
||||
remainingResults.getResults().addAll(results.getResults());
|
||||
|
||||
return remainingResults.getResults().stream().peek(x -> x.put("tag", tag)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||
return remainingResults.getResults().stream().peek(x -> x.put("label", label)).peek(x -> x.put("key", key)).collect(Collectors.toList());
|
||||
}
|
||||
else {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
}
|
||||
|
||||
protected Results getResultsFromUrl(String urlString, ResultsConfigurationEntity jsonResultsPath, String jsonPaginationPath, String contentType, String requestBody, ReferenceTypeExternalApiHTTPMethodType httpMethod, String auth) {
|
||||
private String replaceLookupFields(String urlPath, ReferenceDefinitionSearchLookup lookup, String firstPage, List<QueryConfigEntity> queries){
|
||||
String completedPath = urlPath;
|
||||
|
||||
if (urlPath.contains("{like}")){
|
||||
if (lookup.getLike() != null) {
|
||||
completedPath = completedPath.replace("{like}", lookup.getLike());
|
||||
} else {
|
||||
completedPath = completedPath.replace("{like}", "*");
|
||||
}
|
||||
}
|
||||
|
||||
if (urlPath.contains("{page}")){
|
||||
if (lookup.getPage() != null && lookup.getPage().getOffset() > 0) {
|
||||
completedPath = completedPath.replace("{page}", String.valueOf(lookup.getPage().getOffset()));
|
||||
} else {
|
||||
completedPath = completedPath.replace("{page}", "1");
|
||||
}
|
||||
}
|
||||
|
||||
if (urlPath.contains("{pageSize}")){
|
||||
if (lookup.getPage() != null && lookup.getPage().getSize() > 0) {
|
||||
completedPath = completedPath.replace("{pageSize}", String.valueOf(lookup.getPage().getSize()));
|
||||
} else {
|
||||
completedPath = completedPath.replace("{pageSize}", "100");
|
||||
}
|
||||
}
|
||||
|
||||
if (urlPath.contains("openaire")){
|
||||
if (lookup.getLike() != null) {
|
||||
completedPath = completedPath.replace("{query}", lookup.getLike());
|
||||
} else {
|
||||
completedPath = completedPath.replace("{query}", "*");
|
||||
}
|
||||
}
|
||||
|
||||
return completedPath;
|
||||
}
|
||||
|
||||
protected Results getResultsFromUrl(String urlString, ResultsConfigurationEntity resultsEntity, String jsonPaginationPath, String contentType, String requestBody, ReferenceTypeExternalApiHTTPMethodType httpMethod, String auth) {
|
||||
|
||||
try {
|
||||
ResponseEntity<String> response;
|
||||
|
@ -412,7 +458,7 @@ public class ReferenceService {
|
|||
Results results = new Results();
|
||||
if (response.getHeaders().get("Content-Type").get(0).contains("json")) {
|
||||
DocumentContext jsonContext = JsonPath.parse(response.getBody());
|
||||
results = this.getFromJson(jsonContext, jsonResultsPath);
|
||||
results = this.getFromJson(jsonContext, resultsEntity);
|
||||
}
|
||||
|
||||
|
||||
|
@ -430,24 +476,24 @@ public class ReferenceService {
|
|||
}
|
||||
|
||||
|
||||
public static Results getFromJson(DocumentContext jsonContext, ResultsConfigurationEntity jsonResultsPath) {
|
||||
return new Results(parseData(jsonContext, jsonResultsPath),
|
||||
public static Results getFromJson(DocumentContext jsonContext, ResultsConfigurationEntity resultsEntity) {
|
||||
return new Results(parseData(jsonContext, resultsEntity),
|
||||
new HashMap<>(1, 1));
|
||||
}
|
||||
|
||||
|
||||
private static List<Map<String, String>> parseData (DocumentContext jsonContext, ResultsConfigurationEntity jsonResultsPath) {
|
||||
List <Map<String, String>> rawData = jsonContext.read(jsonResultsPath.getResultsArrayPath());
|
||||
private static List<Map<String, String>> parseData (DocumentContext jsonContext, ResultsConfigurationEntity resultsEntity) {
|
||||
List <Map<String, String>> rawData = jsonContext.read(resultsEntity.getResultsArrayPath());
|
||||
List<Map<String, String>> parsedData = new ArrayList<>();
|
||||
rawData.forEach(stringObjectMap -> {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
jsonResultsPath.getFieldsMapping().forEach(field ->{
|
||||
resultsEntity.getFieldsMapping().forEach(field ->{
|
||||
String pathValue = field.getResponsePath();
|
||||
if (stringObjectMap.containsKey(pathValue)){
|
||||
map.put(field.getCode(), stringObjectMap.get(pathValue));
|
||||
parsedData.add(map);
|
||||
}
|
||||
});
|
||||
parsedData.add(map);
|
||||
|
||||
|
||||
});
|
||||
|
|
|
@ -132,6 +132,8 @@
|
|||
</mat-card-content>
|
||||
</div>
|
||||
</div>
|
||||
<button mat-button class="action-btn" *ngIf="formGroup.get('definition').get('fields').value != ''"
|
||||
type="button" (click)="submitFields()" [disabled]="!formGroup.get('definition').get('fields').valid">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
|
@ -146,7 +148,7 @@
|
|||
</mat-card-header>
|
||||
<mat-card-content>
|
||||
<form (ngSubmit)="formSubmit()" [formGroup]="formGroup" *ngIf="formGroup">
|
||||
<!-- External Api Config Info -->
|
||||
<!-- Source Config Info -->
|
||||
<div class="col-12">
|
||||
<div *ngFor="let source of formGroup.get('definition').get('sources').controls; let sourceIndex=index;" class="row mb-3" cdkDrag [cdkDragDisabled]="formGroup.disabled">
|
||||
<div class="col-12">
|
||||
|
|
|
@ -117,7 +117,9 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
|
||||
ngOnInit(): void {
|
||||
super.ngOnInit();
|
||||
//this.addSource();
|
||||
if((this.formGroup.get('definition').get('sources') as FormArray).length == 0){
|
||||
this.addSource();
|
||||
}
|
||||
}
|
||||
|
||||
getItem(itemId: Guid, successFunction: (item: ReferenceType) => void) {
|
||||
|
@ -225,14 +227,6 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
|
||||
// }
|
||||
|
||||
// const sourceSize = (this.formGroup.get('definition').get('sources') as FormArray).length;
|
||||
|
||||
// if(sourceSize && sourceSize > 0){
|
||||
// for(let i =0; i < sourceSize; i++){
|
||||
// this.addFieldMapping(i);
|
||||
// this.addOption(i);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
@ -247,21 +241,36 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
fieldssFormArray.updateValueAndValidity();
|
||||
}
|
||||
|
||||
submitFields(): void{
|
||||
const fieldssFormArray = (this.formGroup.get('definition').get('fields') as FormArray);
|
||||
|
||||
if (fieldssFormArray.valid){
|
||||
|
||||
const sourceSize = (this.formGroup.get('definition').get('sources') as FormArray).length;
|
||||
if(sourceSize && sourceSize > 0){
|
||||
for(let i =0; i < sourceSize; i++){
|
||||
this.addFieldMapping(i, fieldssFormArray.at(i).get('code').value);
|
||||
this.addOption(i, fieldssFormArray.at(i).get('code').value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addSource(): void{
|
||||
const source: ReferenceTypeSourceBaseConfigurationEditorModel = new ReferenceTypeSourceBaseConfigurationEditorModel();
|
||||
(this.formGroup.get('definition').get('sources') as FormArray).push(source.buildForm());
|
||||
const sourceIndex = (this.formGroup.get('definition').get('sources') as FormArray).length - 1;
|
||||
this.systemFieldsMapping.forEach(x => {
|
||||
this.addFieldMapping(sourceIndex);
|
||||
this.addOption(sourceIndex);
|
||||
this.addFieldMapping(sourceIndex, null);
|
||||
this.addOption(sourceIndex, null);
|
||||
});
|
||||
|
||||
const fieldsSize = (this.formGroup.get('definition').get('fields') as FormArray).length;
|
||||
if(fieldsSize && fieldsSize > 0){
|
||||
for(let i =0; i < fieldsSize; i++){
|
||||
this.addFieldMapping(sourceIndex);
|
||||
this.addOption(sourceIndex);
|
||||
this.addFieldMapping(sourceIndex, null);
|
||||
this.addOption(sourceIndex, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,9 +284,23 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
// resultFieldsMapping
|
||||
//
|
||||
//
|
||||
addFieldMapping(sourceIndex: number): void {
|
||||
addFieldMapping(sourceIndex: number, code: string): void {
|
||||
const fieldMapping: ResultFieldsMappingConfigurationEditorModel = new ResultFieldsMappingConfigurationEditorModel();
|
||||
//((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('results').get('fieldsMapping') as FormArray).push(fieldMapping.buildForm());
|
||||
|
||||
const fieldMappingSize = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('results').get('fieldsMapping') as FormArray).length;
|
||||
|
||||
if (fieldMappingSize>0){
|
||||
for(let i=0; i<fieldMappingSize; i++){
|
||||
if(((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('results').get('fieldsMapping') as FormArray).at(i).get('code').value == code){
|
||||
console.log('error');
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('results').get('fieldsMapping') as FormArray).push(fieldMapping.buildForm());
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('results').get('fieldsMapping') as FormArray).at(fieldMappingSize).get('code').setValue('1');
|
||||
}
|
||||
|
||||
removeFieldMapping(sourceIndex: number, fieldMappingIndex: number): void {
|
||||
|
@ -317,9 +340,21 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
|||
|
||||
// Options
|
||||
|
||||
addOption(sourceIndex: number): void {
|
||||
addOption(sourceIndex: number, code: string): void {
|
||||
const options: ReferenceTypeStaticOptionEditorModel = new ReferenceTypeStaticOptionEditorModel();
|
||||
const optionsSize = ((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('options') as FormArray).length;
|
||||
|
||||
if (optionsSize>0){
|
||||
for(let i=0; i<optionsSize; i++){
|
||||
if(((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('options') as FormArray).at(i).get('code').value == code){
|
||||
console.log('error');
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('options') as FormArray).push(options.buildForm());
|
||||
((this.formGroup.get('definition').get('sources') as FormArray).at(sourceIndex).get('options') as FormArray).at(optionsSize).get('code').setValue('1');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,8 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
|
|||
code: [{ value: this.code, disabled: disabled }, context.getValidation('code').validators],
|
||||
definition: this.definition.buildForm({
|
||||
rootPath: `definition.`
|
||||
})
|
||||
}),
|
||||
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -52,6 +53,7 @@ export class ReferenceTypeEditorModel extends BaseEditorModel implements Referen
|
|||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(this.validationErrorModel, 'id')] });
|
||||
baseValidationArray.push({ key: 'name', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'name')] });
|
||||
baseValidationArray.push({ key: 'code', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'code')] });
|
||||
baseValidationArray.push({ key: 'hash', validators: [] });
|
||||
|
||||
baseContext.validation = baseValidationArray;
|
||||
return baseContext;
|
||||
|
|
|
@ -1046,9 +1046,11 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
|
|||
// lookup.type = ReferenceType.Researcher;
|
||||
// return this.referenceService.search(lookup);
|
||||
const lookup = new ReferenceSearchDefinitionLookup();
|
||||
//lookup.like='';
|
||||
//lookup.page.size = 1;
|
||||
lookup.key = '';
|
||||
//from reference type db hardcoded
|
||||
lookup.referenceTypeId = Guid.parse('c8400d41-28f1-477a-8fa1-3351876fca4f');
|
||||
lookup.referenceTypeId = Guid.parse('51225b6a-86a6-48ac-9192-f15096dbcb8a');
|
||||
const fields = [
|
||||
...ReferenceTypeEditorResolver.lookupFields()
|
||||
];
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>eu.eudat</groupId>
|
||||
<artifactId>dmp-backend</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>core</artifactId>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,43 @@
|
|||
package eu.eudat.commons.enums;
|
||||
|
||||
public enum DescriptionTemplateTypeStatus {
|
||||
|
||||
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
||||
|
||||
private final short value;
|
||||
|
||||
DescriptionTemplateTypeStatus(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static DescriptionTemplateTypeStatus fromInteger(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return SAVED;
|
||||
case 1:
|
||||
return FINALIZED;
|
||||
case 99:
|
||||
return DELETED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Description Template Type Status");
|
||||
}
|
||||
}
|
||||
|
||||
public static DescriptionTemplateTypeStatus fromLabel(String value) {
|
||||
switch (value) {
|
||||
case "SAVED":
|
||||
return SAVED;
|
||||
case "FINALISED":
|
||||
return FINALIZED;
|
||||
case "DELETED":
|
||||
return DELETED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Description Template Type Status");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package eu.eudat.configurations.typedefinition;
|
||||
|
||||
public enum DataType {
|
||||
TINY,
|
||||
SHORT,
|
||||
INTEGER,
|
||||
LONG,
|
||||
DOUBLE,
|
||||
FLOAT,
|
||||
DATE,
|
||||
STRING,
|
||||
TEXT
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package eu.eudat.configurations.typedefinition;
|
||||
|
||||
public interface DatabaseColumnType {
|
||||
public String getType(DataType dt);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package eu.eudat.configurations.typedefinition;
|
||||
|
||||
public class PostgreSQLDatabaseColumnType implements DatabaseColumnType {
|
||||
|
||||
public String getType(DataType dt) {
|
||||
switch (dt) {
|
||||
case TINY:
|
||||
case SHORT:
|
||||
case INTEGER:
|
||||
return "integer";
|
||||
case LONG:
|
||||
return "bigint";
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
return "numeric";
|
||||
case DATE:
|
||||
return "timestamp";
|
||||
case STRING:
|
||||
return "character varying(250)";
|
||||
case TEXT:
|
||||
return "text";
|
||||
}
|
||||
return "character varying(250)";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package eu.eudat.configurations.typedefinition;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
public class PostgreSQLEnumType extends org.hibernate.type.EnumType {
|
||||
|
||||
public void nullSafeSet(
|
||||
PreparedStatement st,
|
||||
Object value,
|
||||
int index,
|
||||
SharedSessionContractImplementor session)
|
||||
throws HibernateException, SQLException {
|
||||
st.setObject(
|
||||
index,
|
||||
value != null ?
|
||||
((Enum) value).name() :
|
||||
null,
|
||||
Types.OTHER
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package eu.eudat.configurations.typedefinition;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Currently not used
|
||||
*/
|
||||
public class UUIDType implements UserType<UUID> {
|
||||
private final int[] sqlTypesSupported = new int[]{Types.NUMERIC};
|
||||
private final String CAST_EXCEPTION_TEXT = " cannot be cast to a java.util.UUID";
|
||||
|
||||
public int[] sqlTypes() {
|
||||
return sqlTypesSupported;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSqlType() {
|
||||
return sqlTypesSupported[0];
|
||||
}
|
||||
|
||||
public Class<UUID> returnedClass() {
|
||||
return UUID.class;
|
||||
}
|
||||
|
||||
public boolean equals(UUID x, UUID y) throws HibernateException {
|
||||
if (x == null) return y == null;
|
||||
else return x.equals(y);
|
||||
}
|
||||
|
||||
public int hashCode(UUID x) throws HibernateException {
|
||||
return x == null ? -1 : x.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
||||
assert (names.length == 1);
|
||||
Object value = rs.getObject(names[0]);
|
||||
if (value == null) return null;
|
||||
|
||||
UUID uuid = UUID.fromString(rs.getString(names[0]));
|
||||
return rs.wasNull() ? null : uuid;
|
||||
}
|
||||
|
||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
||||
if (value == null) {
|
||||
st.setNull(index, Types.NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UUID.class.isAssignableFrom(value.getClass()))
|
||||
throw new HibernateException(value.getClass().toString() + CAST_EXCEPTION_TEXT);
|
||||
|
||||
UUID uuid = (UUID) value;
|
||||
st.setObject(index, uuid, Types.OTHER);
|
||||
}
|
||||
|
||||
public UUID deepCopy(UUID value) throws HibernateException {
|
||||
if (value == null) return null;
|
||||
return new UUID(value.getMostSignificantBits(), value.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Serializable disassemble(UUID value) throws HibernateException {
|
||||
return value;
|
||||
}
|
||||
|
||||
public UUID assemble(Serializable cached, Object owner) throws HibernateException {
|
||||
return (UUID) cached;
|
||||
}
|
||||
|
||||
public UUID replace(UUID original, Object target, Object owner) throws HibernateException {
|
||||
return original;
|
||||
}
|
||||
|
||||
// public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||
// throws HibernateException, SQLException
|
||||
// {
|
||||
// return nullSafeGet(rs, names, owner);
|
||||
// }
|
||||
//
|
||||
// public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
||||
// throws HibernateException, SQLException
|
||||
// {
|
||||
// nullSafeSet(st, value, index);
|
||||
//
|
||||
// }
|
||||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
|
||||
throws HibernateException, SQLException {
|
||||
return nullSafeGet(rs, names, owner);
|
||||
}
|
||||
|
||||
public void nullSafeSet(PreparedStatement st, UUID value, int index, SharedSessionContractImplementor session)
|
||||
throws HibernateException, SQLException {
|
||||
nullSafeSet(st, value, index);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package eu.eudat.configurations.typedefinition;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
/**
|
||||
* Store and retrieve a PostgreSQL "xml" column as a Java string.
|
||||
*/
|
||||
public class XMLType implements UserType<String> {
|
||||
|
||||
private final int[] sqlTypesSupported = new int[]{Types.VARCHAR};
|
||||
|
||||
public int[] sqlTypes() {
|
||||
return sqlTypesSupported;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSqlType() {
|
||||
return sqlTypesSupported[0];
|
||||
}
|
||||
|
||||
public Class<String> returnedClass() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
public boolean equals(String x, String y) throws HibernateException {
|
||||
if (x == null) {
|
||||
return y == null;
|
||||
} else {
|
||||
return x.equals(y);
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode(String x) throws HibernateException {
|
||||
return x == null ? -1 : x.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nullSafeGet(ResultSet resultSet, int i, SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws SQLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
||||
assert (names.length == 1);
|
||||
String xmldoc = rs.getString(names[0]);
|
||||
return rs.wasNull() ? null : xmldoc;
|
||||
}
|
||||
|
||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
||||
if (value == null) {
|
||||
st.setNull(index, Types.OTHER);
|
||||
} else {
|
||||
st.setObject(index, value, Types.OTHER);
|
||||
}
|
||||
}
|
||||
|
||||
public String deepCopy(String value) throws HibernateException {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Serializable disassemble(String value) throws HibernateException {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String assemble(Serializable cached, Object owner) throws HibernateException {
|
||||
return (String) cached;
|
||||
}
|
||||
|
||||
public String replace(String original, String target, Object owner) throws HibernateException {
|
||||
return original;
|
||||
}
|
||||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
|
||||
throws HibernateException, SQLException {
|
||||
return nullSafeGet(rs, names, owner);
|
||||
}
|
||||
|
||||
public void nullSafeSet(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
|
||||
nullSafeSet(st, value, index);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package eu.eudat.convention;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface ConventionService {
|
||||
|
||||
Boolean isValidId(Integer id);
|
||||
|
||||
Boolean isValidGuid(UUID guid);
|
||||
|
||||
Boolean isValidUUID(String str);
|
||||
UUID parseUUIDSafe(String str);
|
||||
|
||||
Boolean isValidHash(String hash);
|
||||
|
||||
String hashValue(Object value);
|
||||
|
||||
String limit(String text, int maxLength);
|
||||
|
||||
String truncate(String text, int maxLength);
|
||||
|
||||
UUID getEmptyUUID();
|
||||
|
||||
boolean isNullOrEmpty(String value);
|
||||
|
||||
boolean isListNullOrEmpty(List<?> value);
|
||||
|
||||
String stringEmpty();
|
||||
|
||||
String asPrefix(String name);
|
||||
|
||||
String asIndexerPrefix(String part);
|
||||
|
||||
String asIndexer(String... names);
|
||||
|
||||
<K, V> Map<K, List<V>> toDictionaryOfList(List<V> items, Function<V, K> keySelector);
|
||||
}
|
|
@ -0,0 +1,150 @@
|
|||
package eu.eudat.convention;
|
||||
|
||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON)
|
||||
public class ConventionServiceImpl implements ConventionService {
|
||||
private final static Pattern UUID_REGEX_PATTERN = Pattern.compile("^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$");
|
||||
|
||||
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(ConventionServiceImpl.class));
|
||||
private final ErrorThesaurusProperties errors;
|
||||
|
||||
@Autowired
|
||||
public ConventionServiceImpl(ErrorThesaurusProperties errors) {
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isValidId(Integer id) {
|
||||
return id != null && id > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isValidGuid(UUID guid) {
|
||||
return guid != null && !guid.equals(this.getEmptyUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isValidUUID(String str) {
|
||||
if (this.isNullOrEmpty(str)) {
|
||||
return false;
|
||||
}
|
||||
return UUID_REGEX_PATTERN.matcher(str).matches();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID parseUUIDSafe(String str) {
|
||||
if (!this.isValidUUID(str)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return UUID.fromString(str);
|
||||
} catch (Exception ex){
|
||||
logger.warn("invalid uuid" + str, ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isValidHash(String hash) {
|
||||
return !this.isNullOrEmpty(hash);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String hashValue(Object value) throws MyApplicationException {
|
||||
if (value == null) return this.stringEmpty();
|
||||
if (value instanceof Instant) return String.format("%ts", (Instant) value);
|
||||
throw new MyApplicationException(this.errors.getSystemError().getCode(), this.errors.getSystemError().getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String limit(String text, int maxLength) {
|
||||
if (this.isNullOrEmpty(text)) return text;
|
||||
if (text.length() > maxLength) return String.format("%s...", text.substring(0, maxLength));
|
||||
else return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String truncate(String text, int maxLength) {
|
||||
String truncated = text;
|
||||
if (text.length() < maxLength) return text;
|
||||
|
||||
truncated = truncated.trim();
|
||||
truncated = truncated.replaceAll("\\s+", " ");//remove multiple spaces
|
||||
if (truncated.length() < maxLength) return truncated;
|
||||
truncated = truncated.replaceAll("([.!@#$%^&-=':;,<>?*\"/|])+", "");//remove multiple spaces
|
||||
if (truncated.length() < maxLength) return truncated;
|
||||
truncated = truncated.replaceAll("([aeiou])+", "");//remove multiple spaces
|
||||
if (truncated.length() < maxLength) return truncated;
|
||||
truncated = truncated.replaceAll("([AEIOU])+", "");//remove multiple spaces
|
||||
if (truncated.length() < maxLength) return truncated;
|
||||
|
||||
if (text.length() > maxLength) return String.format("%s...", text.substring(0, maxLength));
|
||||
return text;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getEmptyUUID() {
|
||||
return new UUID(0L, 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNullOrEmpty(String value) {
|
||||
return value == null || value.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListNullOrEmpty(List<?> value) {
|
||||
if(value == null) return true;
|
||||
return value.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stringEmpty() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asPrefix(String name) {
|
||||
if (name == null) return null;
|
||||
return name + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asIndexer(String... names) {
|
||||
if (names == null) return null;
|
||||
return String.join(".", Arrays.stream(names).filter(x -> !this.isNullOrEmpty(x)).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asIndexerPrefix(String part) {
|
||||
if (part == null) return null;
|
||||
return part + ".";
|
||||
}
|
||||
|
||||
@Override
|
||||
public <K, V> Map<K, List<V>> toDictionaryOfList(List<V> items, Function<V, K> keySelector) {
|
||||
Map<K, List<V>> map = new HashMap<>();
|
||||
for (V model : items) {
|
||||
K key = keySelector.apply(model);
|
||||
if (!map.containsKey(key)) map.put(key, new ArrayList<V>());
|
||||
map.get(key).add(model);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package eu.eudat.data;
|
||||
|
||||
public interface BaseEntity {
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package eu.eudat.data;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "DescriptionTemplateType")
|
||||
public class DescriptionTemplateTypeEntity implements BaseEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "ID", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
public static final String _id = "ID";
|
||||
|
||||
@Column(name = "Name", nullable = false)
|
||||
private String name;
|
||||
|
||||
public static final String _name = "Name";
|
||||
|
||||
@Column(name = "Status", nullable = false)
|
||||
private Short status;
|
||||
|
||||
public static final String _status = "Status";
|
||||
|
||||
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 Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package eu.eudat.errorcode;
|
||||
|
||||
public class ErrorDescription {
|
||||
|
||||
private int code;
|
||||
|
||||
private String message;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.eudat.errorcode;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(ErrorThesaurusProperties.class)
|
||||
public class ErrorThesaurusConfiguration {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package eu.eudat.errorcode;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "error-thesaurus")
|
||||
public class ErrorThesaurusProperties {
|
||||
|
||||
private ErrorDescription systemError;
|
||||
|
||||
public ErrorDescription getSystemError() {
|
||||
return systemError;
|
||||
}
|
||||
|
||||
public void setSystemError(ErrorDescription systemError) {
|
||||
this.systemError = systemError;
|
||||
}
|
||||
|
||||
private ErrorDescription forbidden;
|
||||
|
||||
public ErrorDescription getForbidden() {
|
||||
return forbidden;
|
||||
}
|
||||
|
||||
public void setForbidden(ErrorDescription forbidden) {
|
||||
this.forbidden = forbidden;
|
||||
}
|
||||
|
||||
private ErrorDescription hashConflict;
|
||||
|
||||
public ErrorDescription getHashConflict() {
|
||||
return hashConflict;
|
||||
}
|
||||
|
||||
public void setHashConflict(ErrorDescription hashConflict) {
|
||||
this.hashConflict = hashConflict;
|
||||
}
|
||||
|
||||
private ErrorDescription modelValidation;
|
||||
|
||||
public ErrorDescription getModelValidation() {
|
||||
return modelValidation;
|
||||
}
|
||||
|
||||
public void setModelValidation(ErrorDescription modelValidation) {
|
||||
this.modelValidation = modelValidation;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package eu.eudat.model;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DescriptionTemplateType {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String name;
|
||||
|
||||
private short status;
|
||||
|
||||
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 short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package eu.eudat.model.builder;
|
||||
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import gr.cite.tools.data.builder.Builder;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class BaseBuilder<M, D> implements Builder {
|
||||
|
||||
protected final LoggerService logger;
|
||||
|
||||
protected final ConventionService conventionService;
|
||||
|
||||
public BaseBuilder(
|
||||
ConventionService conventionService,
|
||||
LoggerService logger
|
||||
) {
|
||||
this.conventionService = conventionService;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public M build(FieldSet directives, D data) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
List<M> models = this.build(directives == null ? getFullFieldSet() : directives, List.of(data));
|
||||
return models.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public abstract List<M> build(FieldSet directives, List<D> data);
|
||||
|
||||
public abstract FieldSet getFullFieldSet();
|
||||
|
||||
public <K> Map<K, M> asForeignKey(QueryBase<D> query, FieldSet directives, Function<M, K> keySelector) {
|
||||
this.logger.trace("Building references from query");
|
||||
List<D> data = query.collectAs(directives);
|
||||
this.logger.trace("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
return this.asForeignKey(data, directives, keySelector);
|
||||
}
|
||||
|
||||
public <K> Map<K, M> asForeignKey(List<D> data, FieldSet directives, Function<M, K> keySelector) {
|
||||
this.logger.trace("building references");
|
||||
List<M> models = this.build(directives, data);
|
||||
this.logger.trace("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
assert models != null;
|
||||
return models.stream().collect(Collectors.toMap(keySelector, o -> o));
|
||||
}
|
||||
|
||||
public <K> Map<K, List<M>> asMasterKey(QueryBase<D> query, FieldSet directives, Function<M, K> keySelector) {
|
||||
this.logger.trace("Building details from query");
|
||||
List<D> data = query.collectAs(directives);
|
||||
this.logger.trace("collected {} items to build", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
return this.asMasterKey(data, directives, keySelector);
|
||||
}
|
||||
|
||||
public <K> Map<K, List<M>> asMasterKey(List<D> data, FieldSet directives, Function<M, K> keySelector) {
|
||||
this.logger.trace("building details");
|
||||
List<M> models = this.build(directives, data);
|
||||
this.logger.trace("mapping {} build items from {} requested", Optional.ofNullable(models).map(List::size).orElse(0), Optional.ofNullable(data).map(List::size).orElse(0));
|
||||
Map<K, List<M>> map = new HashMap<>();
|
||||
assert models != null;
|
||||
for (M model : models) {
|
||||
K key = keySelector.apply(model);
|
||||
if (!map.containsKey(key))
|
||||
map.put(key, new ArrayList<M>());
|
||||
map.get(key).add(model);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public <FK, FM> Map<FK, FM> asEmpty(List<FK> keys, Function<FK, FM> mapper, Function<FM, FK> keySelector) {
|
||||
this.logger.trace("building static references");
|
||||
List<FM> models = keys.stream().map(mapper).collect(Collectors.toList());
|
||||
this.logger.trace("mapping {} build items from {} requested", Optional.of(models).map(List::size).orElse(0), Optional.of(keys).map(List::size));
|
||||
return models.stream().collect(Collectors.toMap(keySelector, o -> o));
|
||||
}
|
||||
|
||||
protected String hashValue(Instant value) {
|
||||
return this.conventionService.hashValue(value);
|
||||
}
|
||||
|
||||
protected String asPrefix(String name) {
|
||||
return this.conventionService.asPrefix(name);
|
||||
}
|
||||
|
||||
protected String asIndexer(String... names) {
|
||||
return this.conventionService.asIndexer(names);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package eu.eudat.model.builder;
|
||||
|
||||
import eu.eudat.convention.ConventionService;
|
||||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||
import eu.eudat.model.DescriptionTemplateType;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class DescriptionTemplateTypeBuilder extends BaseBuilder<DescriptionTemplateType, DescriptionTemplateTypeEntity> {
|
||||
|
||||
public DescriptionTemplateTypeBuilder(ConventionService conventionService) {
|
||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateTypeBuilder.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DescriptionTemplateType> build(FieldSet directives, List<DescriptionTemplateTypeEntity> data) {
|
||||
if (directives == null || directives.isEmpty())
|
||||
return new ArrayList<>();
|
||||
|
||||
List<DescriptionTemplateType> models = new ArrayList<>(100);
|
||||
|
||||
if (data == null)
|
||||
return models;
|
||||
for (DescriptionTemplateTypeEntity d : data) {
|
||||
DescriptionTemplateType m = new DescriptionTemplateType();
|
||||
if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._id)))
|
||||
m.setId(d.getId());
|
||||
if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._name)))
|
||||
m.setName(d.getName());
|
||||
if (directives.hasField(this.asIndexer(DescriptionTemplateTypeEntity._status)))
|
||||
m.setStatus(d.getStatus());
|
||||
models.add(m);
|
||||
}
|
||||
|
||||
return models;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FieldSet getFullFieldSet() {
|
||||
BaseFieldSet fieldSet = new BaseFieldSet();
|
||||
fieldSet.setFields(Set.of(
|
||||
DescriptionTemplateTypeEntity._id,
|
||||
DescriptionTemplateTypeEntity._name,
|
||||
DescriptionTemplateTypeEntity._status
|
||||
));
|
||||
return fieldSet;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package eu.eudat.model.result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class QueryResult<M> {
|
||||
|
||||
public QueryResult() {
|
||||
}
|
||||
|
||||
public QueryResult(List<M> items, long count, long countOverride) {
|
||||
this.items = items;
|
||||
this.count = count;
|
||||
this.countOverride = countOverride;
|
||||
}
|
||||
|
||||
public QueryResult(List<M> items, long count) {
|
||||
this.items = items;
|
||||
this.count = count;
|
||||
this.countOverride = 0;
|
||||
}
|
||||
|
||||
public QueryResult(M item) {
|
||||
this.items = List.of(item);
|
||||
this.count = 1;
|
||||
this.countOverride = 0;
|
||||
}
|
||||
|
||||
public QueryResult(List<M> items) {
|
||||
this.items = items;
|
||||
if (items != null)
|
||||
this.count = items.size();
|
||||
else
|
||||
this.count = 0;
|
||||
}
|
||||
|
||||
private List<M> items;
|
||||
|
||||
private long count;
|
||||
|
||||
private long countOverride;
|
||||
|
||||
public List<M> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<M> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public long getCountOverride() {
|
||||
return countOverride;
|
||||
}
|
||||
|
||||
public void setCountOverride(long countOverride) {
|
||||
this.countOverride = countOverride;
|
||||
}
|
||||
|
||||
public static QueryResult<?> empty() {
|
||||
return new QueryResult<>(new ArrayList<>(), 0L);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package eu.eudat.query;
|
||||
|
||||
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
|
||||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||
import eu.eudat.query.lookup.DescriptionTemplateTypeLookup;
|
||||
import eu.eudat.query.lookup.LookupAware;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
import gr.cite.tools.data.query.QueryBase;
|
||||
import gr.cite.tools.data.query.QueryContext;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public class DescriptionTemplateTypeQuery extends QueryBase<DescriptionTemplateTypeEntity> implements LookupAware<DescriptionTemplateTypeQuery, DescriptionTemplateTypeLookup> {
|
||||
|
||||
private Collection<UUID> ids;
|
||||
|
||||
private Collection<String> names;
|
||||
|
||||
private Collection<Short> statuses;
|
||||
|
||||
public DescriptionTemplateTypeQuery ids(UUID value) {
|
||||
this.ids = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeQuery ids(UUID... value) {
|
||||
this.ids = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeQuery ids(List<UUID> value) {
|
||||
this.ids = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeQuery names(String value) {
|
||||
this.names = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeQuery names(String... value) {
|
||||
this.names = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeQuery names(List<String> value) {
|
||||
this.names = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeQuery statuses(Short value) {
|
||||
this.statuses = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeQuery statuses(Short... value) {
|
||||
this.statuses = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DescriptionTemplateTypeQuery statuses(List<Short> value) {
|
||||
this.statuses = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateTypeQuery fromLookup(DescriptionTemplateTypeLookup lookup) {
|
||||
if (lookup == null) return this;
|
||||
if (lookup.getName() != null) names(lookup.getName());
|
||||
if (lookup.getStatus() != null) statuses(DescriptionTemplateTypeStatus.fromLabel(lookup.getStatus()).getValue());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<DescriptionTemplateTypeEntity> entityClass() {
|
||||
return DescriptionTemplateTypeEntity.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||
List<Predicate> predicates = new ArrayList<>();
|
||||
|
||||
if (this.ids != null) {
|
||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._id));
|
||||
for (UUID item : this.ids) inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
|
||||
if (this.names != null) {
|
||||
CriteriaBuilder.In<String> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._name));
|
||||
for (String item : this.names) inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
|
||||
if (this.statuses != null) {
|
||||
CriteriaBuilder.In<Short> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionTemplateTypeEntity._status));
|
||||
for (Short item : this.statuses) inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
return queryContext.CriteriaBuilder.and();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DescriptionTemplateTypeEntity convert(Tuple tuple, Set<String> columns) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import gr.cite.tools.data.query.Lookup;
|
||||
|
||||
public class DescriptionTemplateTypeLookup extends Lookup {
|
||||
|
||||
private String name, status;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
public interface LookupAware<Q, L> {
|
||||
|
||||
/**
|
||||
* Every query that supports building from a lookup object should implement this interface
|
||||
* @param lookup The object containing all the lookup options
|
||||
* @return The query built from all the set options
|
||||
*/
|
||||
Q fromLookup(L lookup);
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package eu.eudat.service;
|
||||
|
||||
import eu.eudat.commons.enums.DescriptionTemplateTypeStatus;
|
||||
import eu.eudat.data.DescriptionTemplateTypeEntity;
|
||||
import eu.eudat.model.DescriptionTemplateType;
|
||||
import eu.eudat.model.builder.DescriptionTemplateTypeBuilder;
|
||||
import eu.eudat.query.DescriptionTemplateTypeQuery;
|
||||
import eu.eudat.query.lookup.DescriptionTemplateTypeLookup;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class DescriptionTemplateTypeService {
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final BuilderFactory builderFactory;
|
||||
|
||||
private final PlatformTransactionManager transactionManager;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
public DescriptionTemplateTypeService(ApplicationContext applicationContext, BuilderFactory builderFactory, PlatformTransactionManager platformTransactionManager) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.builderFactory = builderFactory;
|
||||
this.transactionManager = platformTransactionManager;
|
||||
}
|
||||
|
||||
public List<DescriptionTemplateType> getAll(DescriptionTemplateTypeLookup lookup) {
|
||||
DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
|
||||
return builderFactory
|
||||
.builder(DescriptionTemplateTypeBuilder.class)
|
||||
.build(lookup.getProject(), query.fromLookup(lookup).collect());
|
||||
}
|
||||
|
||||
public DescriptionTemplateType getById(UUID id) {
|
||||
DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
|
||||
return builderFactory
|
||||
.builder(DescriptionTemplateTypeBuilder.class)
|
||||
.build(null, query.ids(id).first());
|
||||
}
|
||||
|
||||
public DescriptionTemplateType create(DescriptionTemplateType payload) {
|
||||
DescriptionTemplateTypeEntity created = new DescriptionTemplateTypeEntity();
|
||||
created.setId(UUID.randomUUID());
|
||||
created.setName(payload.getName());
|
||||
created.setStatus(DescriptionTemplateTypeStatus.SAVED.getValue());
|
||||
|
||||
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
|
||||
definition.setName(UUID.randomUUID().toString());
|
||||
definition.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
|
||||
definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
|
||||
TransactionStatus status = null;
|
||||
try {
|
||||
status = transactionManager.getTransaction(definition);
|
||||
entityManager.persist(created);
|
||||
|
||||
entityManager.flush();
|
||||
transactionManager.commit(status);
|
||||
} catch (Exception ex) {
|
||||
if (status != null)
|
||||
transactionManager.rollback(status);
|
||||
throw ex;
|
||||
}
|
||||
|
||||
DescriptionTemplateTypeQuery query = applicationContext.getBean(DescriptionTemplateTypeQuery.class);
|
||||
return builderFactory
|
||||
.builder(DescriptionTemplateTypeBuilder.class)
|
||||
.build(null, query.ids(created.getId()).first());
|
||||
}
|
||||
|
||||
public DescriptionTemplateType update(DescriptionTemplateType payload) {
|
||||
DescriptionTemplateTypeEntity entity = entityManager.find(DescriptionTemplateTypeEntity.class, payload.getId());
|
||||
entity.setName(payload.getName());
|
||||
entity.setStatus(payload.getStatus());
|
||||
entityManager.merge(entity);
|
||||
entityManager.flush();
|
||||
return builderFactory.builder(DescriptionTemplateTypeBuilder.class).build(null, entity);
|
||||
}
|
||||
|
||||
public boolean delete (UUID id) {
|
||||
DescriptionTemplateTypeEntity entity = entityManager.find(DescriptionTemplateTypeEntity.class, id);
|
||||
if (entity == null) return false;
|
||||
entity.setStatus(DescriptionTemplateTypeStatus.DELETED.getValue());
|
||||
entityManager.merge(entity);
|
||||
entityManager.flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,6 +15,13 @@
|
|||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.eudat</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>dmp-backend</groupId>
|
||||
<artifactId>queryable</artifactId>
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package eu.eudat.data.converters;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.format.datetime.DateFormatter;
|
||||
|
||||
import jakarta.persistence.AttributeConverter;
|
||||
import jakarta.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> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DateToUTCConverter.class);
|
||||
|
||||
@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) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
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) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package eu.eudat.data.dao;
|
||||
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
|
||||
|
||||
public class DatabaseAccess<T extends DataEntity> {
|
||||
|
||||
public DatabaseAccess(DatabaseService<T> databaseService) {
|
||||
this.databaseService = databaseService;
|
||||
}
|
||||
|
||||
private DatabaseService<T> databaseService;
|
||||
|
||||
public DatabaseService<T> getDatabaseService() {
|
||||
return databaseService;
|
||||
}
|
||||
|
||||
public void setDatabaseService(DatabaseService<T> databaseService) {
|
||||
this.databaseService = databaseService;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package eu.eudat.data.dao;
|
||||
|
||||
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface DatabaseAccessLayer<T extends DataEntity, I> {
|
||||
T createOrUpdate(T item);
|
||||
|
||||
CompletableFuture<T> createOrUpdateAsync(T item);
|
||||
|
||||
T find(I id);
|
||||
|
||||
T find(I id, String hint);
|
||||
|
||||
void delete(T item);
|
||||
|
||||
QueryableList<T> asQueryable();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public abstract class Criteria<T> {
|
||||
@ApiModelProperty(value = "like", name = "like", dataType = "String", allowEmptyValue = true, example = "\"\"")
|
||||
private String like;
|
||||
|
||||
public String getLike() {
|
||||
return like;
|
||||
}
|
||||
|
||||
public void setLike(String like) {
|
||||
this.like = like;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
|
||||
public class DataManagementPlanBlueprintCriteria extends Criteria<DMPProfile> {
|
||||
|
||||
private Integer status;
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||
private Date periodStart;
|
||||
private Date periodEnd;
|
||||
private List<eu.eudat.data.entities.Grant> grants;
|
||||
private boolean allVersions;
|
||||
private List<UUID> groupIds;
|
||||
private Integer status;
|
||||
private List<String> organisations;
|
||||
private Integer role;
|
||||
private List<UUID> collaborators;
|
||||
private List<UUID> datasetTemplates;
|
||||
private boolean isPublic;
|
||||
private boolean onlyPublic;
|
||||
private Short grantStatus;
|
||||
private boolean hasDoi;
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
public void setPeriodStart(Date periodStart) {
|
||||
this.periodStart = periodStart;
|
||||
}
|
||||
|
||||
public Date getPeriodEnd() {
|
||||
return periodEnd;
|
||||
}
|
||||
public void setPeriodEnd(Date periodEnd) {
|
||||
this.periodEnd = periodEnd;
|
||||
}
|
||||
|
||||
public List<Grant> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
public void setGrants(List<Grant> grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
public boolean getAllVersions() {
|
||||
return allVersions;
|
||||
}
|
||||
public void setAllVersions(boolean allVersions) {
|
||||
this.allVersions = allVersions;
|
||||
}
|
||||
|
||||
public List<UUID> getGroupIds() {
|
||||
return groupIds;
|
||||
}
|
||||
public void setGroupIds(List<UUID> groupIds) {
|
||||
this.groupIds = groupIds;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<String> getOrganisations() {
|
||||
return organisations;
|
||||
}
|
||||
public void setOrganisations(List<String> organisations) {
|
||||
this.organisations = organisations;
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
return role;
|
||||
}
|
||||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public List<UUID> getCollaborators() {
|
||||
return collaborators;
|
||||
}
|
||||
public void setCollaborators(List<UUID> collaborators) {
|
||||
this.collaborators = collaborators;
|
||||
}
|
||||
|
||||
public List<UUID> getDatasetTemplates() {
|
||||
return datasetTemplates;
|
||||
}
|
||||
public void setDatasetTemplates(List<UUID> datasetTemplates) {
|
||||
this.datasetTemplates = datasetTemplates;
|
||||
}
|
||||
|
||||
public boolean getIsPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
public void setIsPublic(boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
public boolean isOnlyPublic() {
|
||||
return onlyPublic;
|
||||
}
|
||||
|
||||
public void setOnlyPublic(boolean onlyPublic) {
|
||||
this.onlyPublic = onlyPublic;
|
||||
}
|
||||
|
||||
public Short getGrantStatus() {
|
||||
return grantStatus;
|
||||
}
|
||||
|
||||
public void setGrantStatus(Short grantStatus) {
|
||||
this.grantStatus = grantStatus;
|
||||
}
|
||||
|
||||
public boolean hasDoi() {
|
||||
return hasDoi;
|
||||
}
|
||||
|
||||
public void setHasDoi(boolean hasDoi) {
|
||||
this.hasDoi = hasDoi;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public class DataManagementPlanProfileCriteria extends Criteria<DMPProfile> {
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataManagementPlanPublicCriteria extends Criteria<DMP> {
|
||||
private GrantStateType grantStatus;
|
||||
private List<UUID> grants;
|
||||
public List<UUID> datasetProfile;
|
||||
private List<String> dmpOrganisations;
|
||||
private Integer role;
|
||||
private boolean allVersions;
|
||||
private List<UUID> groupIds;
|
||||
|
||||
public GrantStateType getGrantStatus() {
|
||||
return grantStatus;
|
||||
}
|
||||
public void setGrantStatus(GrantStateType grantStatus) {
|
||||
this.grantStatus = grantStatus;
|
||||
}
|
||||
|
||||
public List<UUID> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
public void setGrants(List<UUID> grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
return role;
|
||||
}
|
||||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public boolean getAllVersions() {
|
||||
return allVersions;
|
||||
}
|
||||
public void setAllVersions(boolean allVersions) {
|
||||
this.allVersions = allVersions;
|
||||
}
|
||||
|
||||
public List<UUID> getGroupIds() {
|
||||
return groupIds;
|
||||
}
|
||||
public void setGroupIds(List<UUID> groupIds) {
|
||||
this.groupIds = groupIds;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DataRepository;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataRepositoryCriteria extends Criteria<DataRepository> {
|
||||
|
||||
private UUID creationUserId;
|
||||
|
||||
public UUID getCreationUserId() {
|
||||
return creationUserId;
|
||||
}
|
||||
public void setCreationUserId(UUID creationUserId) {
|
||||
this.creationUserId = creationUserId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.elastic.entities.Tag;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class DatasetCriteria extends Criteria<Dataset> {
|
||||
private Integer status;
|
||||
private Date periodStart;
|
||||
private Date periodEnd;
|
||||
private List<UUID> dmpIds;
|
||||
private List<Tag> tags;
|
||||
private boolean allVersions;
|
||||
private UUID profileDatasetId;
|
||||
private List<String> organisations;
|
||||
private Integer role;
|
||||
private List<UUID> grants;
|
||||
private List<UUID> collaborators;
|
||||
private List<UUID> datasetTemplates;
|
||||
private List<UUID> groupIds;
|
||||
private Boolean isPublic;
|
||||
private Short grantStatus;
|
||||
private boolean hasDoi;
|
||||
|
||||
public boolean getAllVersions() {
|
||||
return allVersions;
|
||||
}
|
||||
public void setAllVersions(boolean allVersions) {
|
||||
this.allVersions = allVersions;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
public void setPeriodStart(Date periodStart) {
|
||||
this.periodStart = periodStart;
|
||||
}
|
||||
|
||||
public Date getPeriodEnd() {
|
||||
return periodEnd;
|
||||
}
|
||||
public void setPeriodEnd(Date periodEnd) {
|
||||
this.periodEnd = periodEnd;
|
||||
}
|
||||
|
||||
public List<UUID> getDmpIds() {
|
||||
return dmpIds;
|
||||
}
|
||||
public void setDmpIds(List<UUID> dmpIds) {
|
||||
this.dmpIds = dmpIds;
|
||||
}
|
||||
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public UUID getProfileDatasetId() {
|
||||
return profileDatasetId;
|
||||
}
|
||||
public void setProfileDatasetId(UUID profileDatasetId) {
|
||||
this.profileDatasetId = profileDatasetId;
|
||||
}
|
||||
|
||||
public List<String> getOrganisations() {
|
||||
return organisations;
|
||||
}
|
||||
public void setOrganisations(List<String> organisations) {
|
||||
this.organisations = organisations;
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
return role;
|
||||
}
|
||||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public List<UUID> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
public void setGrants(List<UUID> grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
public List<UUID> getCollaborators() {
|
||||
return collaborators;
|
||||
}
|
||||
public void setCollaborators(List<UUID> collaborators) {
|
||||
this.collaborators = collaborators;
|
||||
}
|
||||
|
||||
public List<UUID> getDatasetTemplates() {
|
||||
return datasetTemplates;
|
||||
}
|
||||
public void setDatasetTemplates(List<UUID> datasetTemplates) {
|
||||
this.datasetTemplates = datasetTemplates;
|
||||
}
|
||||
|
||||
public List<UUID> getGroupIds() {
|
||||
return groupIds;
|
||||
}
|
||||
public void setGroupIds(List<UUID> groupIds) {
|
||||
this.groupIds = groupIds;
|
||||
}
|
||||
|
||||
public Boolean getIsPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public void setIsPublic(Boolean isPublic) {
|
||||
this.isPublic = isPublic;
|
||||
}
|
||||
|
||||
public Short getGrantStatus() {
|
||||
return grantStatus;
|
||||
}
|
||||
|
||||
public void setGrantStatus(Short grantStatus) {
|
||||
this.grantStatus = grantStatus;
|
||||
}
|
||||
|
||||
public boolean hasDoi() {
|
||||
return hasDoi;
|
||||
}
|
||||
|
||||
public void setHasDoi(boolean hasDoi) {
|
||||
this.hasDoi = hasDoi;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
|
||||
|
||||
public enum DatasetProfileFilter {
|
||||
DMPs((short) 0), Datasets((short) 1);
|
||||
|
||||
private short value;
|
||||
private DatasetProfileFilter(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
public short getValue() { return value; }
|
||||
|
||||
public static DatasetProfileFilter fromInteger(short value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return DMPs;
|
||||
case 1:
|
||||
return Datasets;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported DescriptionTemplate filter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean allVersions;
|
||||
private List<UUID> groupIds;
|
||||
private Short filter;
|
||||
private UUID userId;
|
||||
private boolean finalized;
|
||||
private Integer status;
|
||||
private Integer role;
|
||||
private List<UUID> ids;
|
||||
private Date periodStart;
|
||||
|
||||
public boolean getAllVersions() { return allVersions; }
|
||||
public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
|
||||
|
||||
public List<UUID> getGroupIds() { return groupIds; }
|
||||
public void setGroupIds(List<UUID> groupIds) { this.groupIds = groupIds; }
|
||||
|
||||
public Short getFilter() {
|
||||
return filter;
|
||||
}
|
||||
public void setFilter(Short filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public boolean getFinalized() {
|
||||
return finalized;
|
||||
}
|
||||
public void setFinalized(boolean finalized) {
|
||||
this.finalized = finalized;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public List<UUID> getIds() {
|
||||
return ids;
|
||||
}
|
||||
|
||||
public void setIds(List<UUID> ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
|
||||
public void setPeriodStart(Date periodStart) {
|
||||
this.periodStart = periodStart;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class DatasetProfileWizardCriteria extends Criteria<DescriptionTemplate> {
|
||||
private UUID id;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.elastic.entities.Tag;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 10/2/2018.
|
||||
*/
|
||||
public class DatasetPublicCriteria extends Criteria<Dataset>{
|
||||
private GrantStateType grantStatus;
|
||||
private List<UUID> grants;
|
||||
private List<UUID> datasetProfile;
|
||||
private List<String> dmpOrganisations;
|
||||
private List<Tag> tags;
|
||||
private List<UUID> dmpIds;
|
||||
private Integer role;
|
||||
|
||||
public GrantStateType getGrantStatus() {
|
||||
return grantStatus;
|
||||
}
|
||||
public void setGrantStatus(GrantStateType grantStatus) {
|
||||
this.grantStatus = grantStatus;
|
||||
}
|
||||
|
||||
public List<UUID> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
public void setGrants(List<UUID> grants) {
|
||||
this.grants = grants;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public List<UUID> getDmpIds() {
|
||||
return dmpIds;
|
||||
}
|
||||
public void setDmpIds(List<UUID> dmpIds) {
|
||||
this.dmpIds = dmpIds;
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
return role;
|
||||
}
|
||||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
|
||||
public class DatasetWizardUserDmpCriteria extends Criteria<DMP> {
|
||||
private UserInfo userInfo;
|
||||
|
||||
public UserInfo getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
public void setUserInfo(UserInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/26/2018.
|
||||
*/
|
||||
public class DynamicFieldsCriteria extends Criteria {
|
||||
public static class DynamicFieldDependencyCriteria {
|
||||
private String property;
|
||||
private String value;
|
||||
|
||||
public DynamicFieldDependencyCriteria() {
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private String id;
|
||||
private List<DynamicFieldDependencyCriteria> dynamicFields;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<DynamicFieldDependencyCriteria> getDynamicFields() {
|
||||
return dynamicFields;
|
||||
}
|
||||
|
||||
public void setDynamicFields(List<DynamicFieldDependencyCriteria> dynamicFields) {
|
||||
this.dynamicFields = dynamicFields;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.EmailConfirmation;
|
||||
|
||||
public class EmailConfirmationCriteria extends Criteria<EmailConfirmation>{
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.ExternalDataset;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ExternalDatasetCriteria extends Criteria<ExternalDataset> {
|
||||
private UUID creationUserId;
|
||||
|
||||
public UUID getCreationUserId() {
|
||||
return creationUserId;
|
||||
}
|
||||
public void setCreationUserId(UUID creationUserId) {
|
||||
this.creationUserId = creationUserId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Funder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class FunderCriteria extends Criteria<Funder> {
|
||||
private String reference;
|
||||
private String exactReference;
|
||||
private Date periodStart;
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String getExactReference() {
|
||||
return exactReference;
|
||||
}
|
||||
|
||||
public void setExactReference(String exactReference) {
|
||||
this.exactReference = exactReference;
|
||||
}
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
|
||||
public void setPeriodStart(Date periodStart) {
|
||||
this.periodStart = periodStart;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class GrantCriteria extends Criteria<Grant> {
|
||||
private Date periodStart;
|
||||
private Date periodEnd;
|
||||
private String reference;
|
||||
private Integer grantStateType;
|
||||
private boolean isPublic;
|
||||
private String funderId;
|
||||
private String funderReference;
|
||||
private String exactReference;
|
||||
private boolean isActive;
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
public void setPeriodStart(Date periodStart) {
|
||||
this.periodStart = periodStart;
|
||||
}
|
||||
|
||||
public Date getPeriodEnd() {
|
||||
return periodEnd;
|
||||
}
|
||||
public void setPeriodEnd(Date periodEnd) {
|
||||
this.periodEnd = periodEnd;
|
||||
}
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public Integer getGrantStateType() {
|
||||
return grantStateType;
|
||||
}
|
||||
public void setGrantStateType(Integer grantStateType) {
|
||||
this.grantStateType = grantStateType;
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
public void setPublic(boolean aPublic) {
|
||||
isPublic = aPublic;
|
||||
}
|
||||
|
||||
public String getFunderId() {
|
||||
return funderId;
|
||||
}
|
||||
public void setFunderId(String funderId) {
|
||||
this.funderId = funderId;
|
||||
}
|
||||
|
||||
public String getFunderReference() {
|
||||
return funderReference;
|
||||
}
|
||||
public void setFunderReference(String funderReference) {
|
||||
this.funderReference = funderReference;
|
||||
}
|
||||
|
||||
public String getExactReference() {
|
||||
return exactReference;
|
||||
}
|
||||
|
||||
public void setExactReference(String exactReference) {
|
||||
this.exactReference = exactReference;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Invitation;
|
||||
|
||||
public class InvitationCriteria extends Criteria<Invitation> {
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Lock;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LockCriteria extends Criteria<Lock> {
|
||||
|
||||
private UUID target;
|
||||
private UserInfo lockedBy;
|
||||
private Date touchedAt;
|
||||
|
||||
public UUID getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(UUID target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public UserInfo getLockedBy() {
|
||||
return lockedBy;
|
||||
}
|
||||
|
||||
public void setLockedBy(UserInfo lockedBy) {
|
||||
this.lockedBy = lockedBy;
|
||||
}
|
||||
|
||||
public Date getTouchedAt() {
|
||||
return touchedAt;
|
||||
}
|
||||
|
||||
public void setTouchedAt(Date touchedAt) {
|
||||
this.touchedAt = touchedAt;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.enumeration.notification.ActiveStatus;
|
||||
import eu.eudat.data.enumeration.notification.NotifyState;
|
||||
|
||||
public class NotificationCriteria {
|
||||
|
||||
private ActiveStatus isActive;
|
||||
private NotifyState notifyState;
|
||||
|
||||
public ActiveStatus getIsActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setIsActive(ActiveStatus isActive) {
|
||||
this.isActive = isActive;
|
||||
}
|
||||
|
||||
public NotifyState getNotifyState() {
|
||||
return notifyState;
|
||||
}
|
||||
|
||||
public void setNotifyState(NotifyState notifyState) {
|
||||
this.notifyState = notifyState;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Organisation;
|
||||
|
||||
public class OrganisationCriteria extends Criteria<Organisation> {
|
||||
private String labelLike;
|
||||
private Boolean isPublic;
|
||||
private boolean isActive;
|
||||
|
||||
public String getLabelLike() {
|
||||
return labelLike;
|
||||
}
|
||||
public void setLabelLike(String labelLike) {
|
||||
this.labelLike = labelLike;
|
||||
}
|
||||
|
||||
public Boolean getPublic() {
|
||||
return isPublic;
|
||||
}
|
||||
public void setPublic(Boolean aPublic) {
|
||||
isPublic = aPublic;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return isActive;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
isActive = active;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Project;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ProjectCriteria extends Criteria<Project> {
|
||||
private String reference;
|
||||
private String exactReference;
|
||||
private Date periodStart;
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String getExactReference() {
|
||||
return exactReference;
|
||||
}
|
||||
|
||||
public void setExactReference(String exactReference) {
|
||||
this.exactReference = exactReference;
|
||||
}
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
|
||||
public void setPeriodStart(Date periodStart) {
|
||||
this.periodStart = periodStart;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Registry;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class RegistryCriteria extends Criteria<Registry> {
|
||||
|
||||
private UUID creationUserId;
|
||||
|
||||
public UUID getCreationUserId() {
|
||||
return creationUserId;
|
||||
}
|
||||
public void setCreationUserId(UUID creationUserId) {
|
||||
this.creationUserId = creationUserId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/26/2018.
|
||||
*/
|
||||
public class RequestItem<T> {
|
||||
T criteria;
|
||||
|
||||
public T getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void setCriteria(T criteria) {
|
||||
this.criteria = criteria;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Researcher;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ResearcherCriteria extends Criteria<Researcher> {
|
||||
private String name;
|
||||
private String reference;
|
||||
private Date periodStart;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
|
||||
public void setPeriodStart(Date periodStart) {
|
||||
this.periodStart = periodStart;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ServiceCriteria extends Criteria<Service> {
|
||||
|
||||
private UUID creationUserId;
|
||||
|
||||
public UUID getCreationUserId() {
|
||||
return creationUserId;
|
||||
}
|
||||
public void setCreationUserId(UUID creationUserId) {
|
||||
this.creationUserId = creationUserId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class UserInfoCriteria extends Criteria<UserInfo> {
|
||||
private String email;
|
||||
private List<Integer> appRoles;
|
||||
private String collaboratorLike;
|
||||
|
||||
public List<Integer> getAppRoles() {
|
||||
return appRoles;
|
||||
}
|
||||
public void setAppRoles(List<Integer> appRoles) {
|
||||
this.appRoles = appRoles;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getCollaboratorLike() {
|
||||
return collaboratorLike;
|
||||
}
|
||||
public void setCollaboratorLike(String collaboratorLike) {
|
||||
this.collaboratorLike = collaboratorLike;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.UserRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/1/2018.
|
||||
*/
|
||||
public class UserRoleCriteria extends Criteria<UserRole> {
|
||||
private List<Integer> appRoles;
|
||||
|
||||
public List<Integer> getAppRoles() {
|
||||
return appRoles;
|
||||
}
|
||||
|
||||
public void setAppRoles(List<Integer> appRoles) {
|
||||
this.appRoles = appRoles;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package eu.eudat.data.dao.databaselayer.context;
|
||||
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.jpa.hibernatequeryablelist.QueryableHibernateList;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.EntityManagerFactory;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
|
||||
|
||||
@Repository("databaseCtx")
|
||||
public class DatabaseContext<T extends DataEntity> {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
public DatabaseContext(EntityManagerFactory entityManagerFactory) {
|
||||
this.entityManager = entityManagerFactory.createEntityManager();
|
||||
}
|
||||
|
||||
public QueryableList<T> getQueryable(Class<T> type) {
|
||||
return new QueryableHibernateList<>(this.entityManager, type).setEntity(type);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public T createOrUpdate(T item, Class<T> type) {
|
||||
EntityManager entityManager = this.entityManager;
|
||||
if (item.getKeys() != null) {
|
||||
T oldItem = entityManager.find(type, item.getKeys());
|
||||
if (oldItem != null) {
|
||||
oldItem.update(item);
|
||||
entityManager.merge(oldItem);
|
||||
return oldItem;
|
||||
} else {
|
||||
entityManager.persist(item);
|
||||
}
|
||||
} else entityManager.persist(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
public void delete(T item) {
|
||||
this.entityManager.remove(item);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package eu.eudat.data.dao.databaselayer.service;
|
||||
|
||||
|
||||
import eu.eudat.data.dao.databaselayer.context.DatabaseContext;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
@Service("databaseService")
|
||||
public class DatabaseService<T extends DataEntity> {
|
||||
|
||||
private DatabaseContext<T> databaseCtx;
|
||||
|
||||
@Autowired
|
||||
public DatabaseService(DatabaseContext<T> databaseCtx) {
|
||||
this.databaseCtx = databaseCtx;
|
||||
}
|
||||
|
||||
public QueryableList<T> getQueryable(Class<T> tClass) {
|
||||
return this.databaseCtx.getQueryable(tClass);
|
||||
}
|
||||
|
||||
public QueryableList<T> getQueryable(Set<String> hints, Class<T> tClass) {
|
||||
return this.databaseCtx.getQueryable(tClass);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public T createOrUpdate(T item, Class<T> tClass) {
|
||||
return this.databaseCtx.createOrUpdate(item, tClass);
|
||||
}
|
||||
|
||||
public void delete(T item) {
|
||||
this.databaseCtx.delete(item);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.Content;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/16/2018.
|
||||
*/
|
||||
public interface ContentDao extends DatabaseAccessLayer<Content, UUID> {
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.Content;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/16/2018.
|
||||
*/
|
||||
@Service("contentDao")
|
||||
public class ContentDaoImpl extends DatabaseAccess<Content> implements ContentDao {
|
||||
|
||||
@Autowired
|
||||
public ContentDaoImpl(DatabaseService<Content> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content createOrUpdate(Content item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, Content.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public CompletableFuture<Content> createOrUpdateAsync(Content item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(Content.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Content find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Content item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Content> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Content.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.UserDMP;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DMPDao extends DatabaseAccessLayer<DMP, UUID> {
|
||||
|
||||
QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria);
|
||||
|
||||
QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo);
|
||||
|
||||
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principalId, List<Integer> roles);
|
||||
|
||||
}
|
|
@ -0,0 +1,149 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.JoinType;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("dMPDao")
|
||||
public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||
|
||||
@Autowired
|
||||
public DMPDaoImpl(DatabaseService<DMP> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria) {
|
||||
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.getHints(), DMP.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.or(
|
||||
builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||
builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%")));
|
||||
if (criteria.getPeriodEnd() != null)
|
||||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
||||
if (!criteria.getAllVersions())
|
||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
||||
query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(
|
||||
builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")),
|
||||
builder1.notEqual(nestedRoot.get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), Integer.class)));
|
||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
||||
if (criteria.getStatus() != null) {
|
||||
if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
||||
} else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
||||
}
|
||||
}
|
||||
if (criteria.getIsPublic()) {
|
||||
query.where(((builder, root) -> builder.equal(root.get("isPublic"), criteria.getIsPublic())));
|
||||
}
|
||||
/*if (criteria.getRole() != null) {
|
||||
if (criteria.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())) {
|
||||
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.OWNER.getValue()));
|
||||
} else if (criteria.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())) {
|
||||
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).get("role"), UserDMP.UserDMPRoles.USER.getValue()));
|
||||
}
|
||||
}*/
|
||||
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty()) {
|
||||
query.where((builder, root) -> root.join("organisations").get("reference").in(criteria.getOrganisations()));
|
||||
}
|
||||
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty()) {
|
||||
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
||||
}
|
||||
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
||||
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
|
||||
}
|
||||
if (criteria.getGrantStatus() != null) {
|
||||
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
||||
query.where((builder, root) -> builder.lessThan(root.get("grant").get("enddate"), new Date()));
|
||||
if (criteria.getGrantStatus().equals(GrantStateType.ONGOING.getValue().shortValue()))
|
||||
query.where((builder, root) ->
|
||||
builder.or(builder.greaterThan(root.get("grant").get("enddate"), new Date())
|
||||
, builder.isNull(root.get("grant").get("enddate"))));
|
||||
}
|
||||
|
||||
if (criteria.hasDoi()) {
|
||||
query.where((builder, root) -> builder.not(builder.isNull(root.join("dois").get("id"))));
|
||||
}
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
||||
public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principal, List<Integer> roles) {
|
||||
if (roles != null && !roles.isEmpty()) {
|
||||
query.where((builder, root) -> {
|
||||
Join userJoin = root.join("users", JoinType.LEFT);
|
||||
return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal), userJoin.get("role").in(roles));
|
||||
});
|
||||
} else {
|
||||
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal));
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DMP createOrUpdate(DMP item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DMP.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMP find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserInfo userInfo) {
|
||||
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"), userInfo), builder.isMember(userInfo, root.get("users"))));
|
||||
if (datasetWizardUserDmpCriteria.getLike() != null && !datasetWizardUserDmpCriteria.getLike().isEmpty()) {
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + datasetWizardUserDmpCriteria.getLike() + "%"));
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DMP item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMP> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DMP.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DMP> createOrUpdateAsync(DMP item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMP find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
public interface DMPProfileDao extends DatabaseAccessLayer<DMPProfile, UUID> {
|
||||
|
||||
QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria);
|
||||
|
||||
QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria);
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
*/
|
||||
@Service("dmpProfileDao")
|
||||
public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMPProfileDao {
|
||||
|
||||
@Autowired
|
||||
public DMPProfileDaoImpl(DatabaseService<DMPProfile> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DMPProfile> createOrUpdateAsync(DMPProfile item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPProfile createOrUpdate(DMPProfile item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DMPProfile.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DMPProfile find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DMPProfile.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPProfile find(UUID id, String hint) {
|
||||
return getDatabaseService().getQueryable(DMPProfile.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DMPProfile item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DMPProfile.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria) {
|
||||
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria){
|
||||
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
||||
if (criteria.getStatus() != null) {
|
||||
if (criteria.getStatus() == DMPProfile.Status.FINALIZED.getValue()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.FINALIZED.getValue()));
|
||||
} else if (criteria.getStatus() == DMPProfile.Status.SAVED.getValue()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.SAVED.getValue()));
|
||||
}
|
||||
}
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
|
||||
return query;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||
import eu.eudat.data.entities.DataRepository;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DataRepositoryDao extends DatabaseAccessLayer<DataRepository, UUID> {
|
||||
QueryableList<DataRepository> getWithCriteria(DataRepositoryCriteria criteria);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DataRepositoryCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DataRepository;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("dataRepositoryDao")
|
||||
public class DataRepositoryDaoImpl extends DatabaseAccess<DataRepository> implements DataRepositoryDao {
|
||||
|
||||
@Autowired
|
||||
public DataRepositoryDaoImpl(DatabaseService<DataRepository> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DataRepository> getWithCriteria(DataRepositoryCriteria criteria) {
|
||||
QueryableList<DataRepository> query = this.getDatabaseService().getQueryable(DataRepository.class);
|
||||
if (criteria.getLike() != null)
|
||||
query.where((builder, root) -> builder.or(
|
||||
builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||
builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
|
||||
if (criteria.getCreationUserId() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), criteria.getCreationUserId()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataRepository find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(DataRepository.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataRepository createOrUpdate(DataRepository item) {
|
||||
return getDatabaseService().createOrUpdate(item, DataRepository.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public CompletableFuture<DataRepository> createOrUpdateAsync(DataRepository item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataRepository find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DataRepository item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DataRepository> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DataRepository.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DatasetDao extends DatabaseAccessLayer<Dataset, UUID> {
|
||||
|
||||
QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria);
|
||||
|
||||
QueryableList<Dataset> filterFromElastic(DatasetCriteria criteria, List<UUID> ids);
|
||||
|
||||
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal, List<Integer> roles);
|
||||
|
||||
Dataset isPublicDataset(UUID id);
|
||||
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.UserDMP;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.JoinType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("datasetDao")
|
||||
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) { super(databaseService); }
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
|
||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
||||
if (criteria.getIsPublic() != null && criteria.getIsPublic()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true));
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()));
|
||||
/*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 (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.or(
|
||||
builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||
builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%")));
|
||||
if (criteria.getStatus() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus()));
|
||||
if (criteria.getProfileDatasetId() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("profile").get("id"), criteria.getProfileDatasetId()));
|
||||
if (criteria.getPeriodEnd() != null)
|
||||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
if (!criteria.getAllVersions())
|
||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), Integer.class)));
|
||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||
query.where((builder, root) -> root.get("dmp").get("groupId").in(criteria.getGroupIds()));
|
||||
if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
|
||||
query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds()));
|
||||
/*if (criteria.getRole() != null) {
|
||||
query.where((builder, root) -> builder.equal(root.join("dmp").join("users").get("role"), criteria.getRole()));
|
||||
} else {
|
||||
query.where((builder, root) -> root.join("dmp").join("users").get("role").in(UserDMP.UserDMPRoles.getAllValues()));
|
||||
}*/
|
||||
if (criteria.getOrganisations() != null && !criteria.getOrganisations().isEmpty())
|
||||
query.where((builder, root) -> root.join("dmp").join("organisations").get("reference").in(criteria.getOrganisations()));
|
||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||
query.where((builder, root) -> root.join("dmp").join("grant").get("id").in(criteria.getGrants()));
|
||||
if (criteria.getGrantStatus() != null) {
|
||||
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
||||
query.where((builder, root) -> builder.lessThan(root.get("dmp").get("grant").get("enddate"), new Date()));
|
||||
if (criteria.getGrantStatus().equals(GrantStateType.ONGOING.getValue().shortValue()))
|
||||
query.where((builder, root) ->
|
||||
builder.or(builder.greaterThan(root.get("dmp").get("grant").get("enddate"), new Date())
|
||||
, builder.isNull(root.get("dmp").get("grant").get("enddate"))));
|
||||
}
|
||||
if (criteria.getCollaborators() != null && !criteria.getCollaborators().isEmpty())
|
||||
query.where((builder, root) -> root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
||||
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty())
|
||||
query.where((builder, root) -> root.get("profile").get("id").in(criteria.getDatasetTemplates()));
|
||||
|
||||
if (criteria.hasDoi()) {
|
||||
query.where((builder, root) -> builder.not(builder.isNull(root.join("dmp").join("dois").get("id"))));
|
||||
}
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
||||
public QueryableList<Dataset> filterFromElastic(DatasetCriteria criteria, List<UUID> ids) {
|
||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
||||
|
||||
query.where(((builder, root) -> root.get("id").in(ids)));
|
||||
if (!criteria.getAllVersions())
|
||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset createOrUpdate(Dataset item) {
|
||||
return getDatabaseService().createOrUpdate(item, Dataset.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset find(UUID id) {
|
||||
return getDatabaseService().getQueryable(Dataset.class)
|
||||
.where((builder, root) -> builder.and(builder.notEqual(root.get("status"),Dataset.Status.DELETED.getValue()), builder.notEqual(root.get("status"),Dataset.Status.CANCELED.getValue()), builder.equal((root.get("id")), id))).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset find(UUID id, String hint) {
|
||||
return getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class).withHint(hint)
|
||||
.where((builder, root) -> builder.and(builder.notEqual(root.get("status"),Dataset.Status.DELETED.getValue()), builder.notEqual(root.get("status"),Dataset.Status.CANCELED.getValue()), builder.equal((root.get("id")), id))).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset isPublicDataset(UUID id) {
|
||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
||||
query.where(((builder, root) -> builder.equal(root.get("id"), id)));
|
||||
|
||||
return query.withHint("datasetListingModel").getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal, List<Integer> roles) {
|
||||
if (roles != null && !roles.isEmpty()) {
|
||||
query.where((builder, root) -> {
|
||||
Join userJoin = root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT);
|
||||
return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal.getId()), userJoin.get("role").in(roles));
|
||||
});
|
||||
} else {
|
||||
query.where((builder, root) -> builder.equal(root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()));
|
||||
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Dataset item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Dataset> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Dataset.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
public CompletableFuture<Dataset> createOrUpdateAsync(Dataset item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DatasetExternalDataset;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
public interface DatasetExternalDatasetDao extends DatabaseAccessLayer<DatasetExternalDataset, UUID> {
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DatasetExternalDataset;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
@Component("datasetExternalDatasetDao")
|
||||
public class DatasetExternalDatasetDaoImpl extends DatabaseAccess<DatasetExternalDataset> implements DatasetExternalDatasetDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetExternalDatasetDaoImpl(DatabaseService<DatasetExternalDataset> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetExternalDataset createOrUpdate(DatasetExternalDataset item) {
|
||||
return this.getDatabaseService().createOrUpdate(item,DatasetExternalDataset.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DatasetExternalDataset> createOrUpdateAsync(DatasetExternalDataset item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public DatasetExternalDataset find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DatasetExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetExternalDataset find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(DatasetExternalDataset item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DatasetExternalDataset> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DatasetExternalDataset.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DatasetProfileDao extends DatabaseAccessLayer<DescriptionTemplate, UUID> {
|
||||
|
||||
QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria);
|
||||
|
||||
QueryableList<DescriptionTemplate> getAll();
|
||||
|
||||
QueryableList<DescriptionTemplate> getAuthenticated(QueryableList<DescriptionTemplate> query, UUID principal, List<Integer> roles);
|
||||
|
||||
List<DescriptionTemplate> getAllIds();
|
||||
|
||||
Long countWithType(DescriptionTemplateType type);
|
||||
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.JoinType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("datasetProfileDao")
|
||||
public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> implements DatasetProfileDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetProfileDaoImpl(DatabaseService<DescriptionTemplate> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria) {
|
||||
QueryableList<DescriptionTemplate> query = getDatabaseService().getQueryable(DescriptionTemplate.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
||||
if (!criteria.getAllVersions())
|
||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
||||
query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"),
|
||||
nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), Integer.class)));
|
||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
||||
if (criteria.getFilter() != null && criteria.getUserId() != null) {
|
||||
if (criteria.getFilter().equals(DatasetProfileCriteria.DatasetProfileFilter.DMPs.getValue())) {
|
||||
query.initSubQuery(UUID.class).where((builder, root) ->
|
||||
builder.and(root.get("id").in(
|
||||
query.subQuery((builder1, root1) -> builder1.equal(root1.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId()),
|
||||
Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")))),
|
||||
builder.notEqual(root.get("id"), criteria.getUserId())));
|
||||
//query.where(((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId())));
|
||||
}
|
||||
if (criteria.getFilter().equals(DatasetProfileCriteria.DatasetProfileFilter.Datasets.getValue())) {
|
||||
query.initSubQuery(UUID.class).where((builder, root) ->
|
||||
builder.and(root.get("id").in(
|
||||
query.subQuery((builder1, root1) -> builder1.equal(root1.join("dataset", JoinType.LEFT).join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), criteria.getUserId()),
|
||||
Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")))),
|
||||
builder.notEqual(root.get("id"), criteria.getUserId())));
|
||||
}
|
||||
}
|
||||
if (criteria.getStatus() != null) {
|
||||
query.where(((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())));
|
||||
}
|
||||
if (criteria.getIds() != null) {
|
||||
query.where(((builder, root) -> root.get("id").in(criteria.getIds())));
|
||||
}
|
||||
if (criteria.getFinalized()) {
|
||||
query.where(((builder, root) -> builder.equal(root.get("status"), DescriptionTemplate.Status.FINALIZED.getValue())));
|
||||
} else {
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DescriptionTemplate.Status.DELETED.getValue())));
|
||||
}
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplate createOrUpdate(DescriptionTemplate item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplate.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplate find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> getAll() {
|
||||
return getDatabaseService().getQueryable(DescriptionTemplate.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DescriptionTemplate> getAllIds(){
|
||||
return getDatabaseService().getQueryable(DescriptionTemplate.class).withFields(Collections.singletonList("id")).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DescriptionTemplate item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplate.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DescriptionTemplate> createOrUpdateAsync(DescriptionTemplate item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplate find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> getAuthenticated(QueryableList<DescriptionTemplate> query, UUID principal, List<Integer> roles) {
|
||||
if (roles != null && !roles.isEmpty()) {
|
||||
query.where((builder, root) -> {
|
||||
Join userJoin = root.join("users", JoinType.LEFT);
|
||||
return builder.and(builder.equal(userJoin.join("user", JoinType.LEFT).get("id"), principal), userJoin.get("role").in(roles));
|
||||
});
|
||||
} else {
|
||||
query.where((builder, root) -> builder.equal(root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal));
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countWithType(DescriptionTemplateType type) {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("type"), type)).count();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DatasetService;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
public interface DatasetServiceDao extends DatabaseAccessLayer<DatasetService, UUID> {
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DatasetService;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 5/22/2018.
|
||||
*/
|
||||
@Component("datasetServiceDao")
|
||||
public class DatasetServiceDaoImpl extends DatabaseAccess<DatasetService> implements DatasetServiceDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetServiceDaoImpl(DatabaseService<DatasetService> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetService createOrUpdate(DatasetService item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DatasetService.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DatasetService> createOrUpdateAsync(DatasetService item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetService find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DatasetService.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetService find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DatasetService item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DatasetService> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DatasetService.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DescriptionTemplateTypeDao extends DatabaseAccessLayer<DescriptionTemplateType, UUID> {
|
||||
DescriptionTemplateType findFromName(String name);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
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.DescriptionTemplateType;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("descriptionTemplateTypeDao")
|
||||
public class DescriptionTemplateTypeDaoImpl extends DatabaseAccess<DescriptionTemplateType> implements DescriptionTemplateTypeDao {
|
||||
|
||||
@Autowired
|
||||
public DescriptionTemplateTypeDaoImpl(DatabaseService<DescriptionTemplateType> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType findFromName(String name){
|
||||
try {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal(root.get("name"), name)).getSingle();
|
||||
}
|
||||
catch(Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DescriptionTemplateType createOrUpdate(DescriptionTemplateType item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplateType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DescriptionTemplateType item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplateType> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.notEqual((root.get("status")), DescriptionTemplateType.Status.DELETED.getValue()));
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DescriptionTemplateType> createOrUpdateAsync(DescriptionTemplateType item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DMPDatasetProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DmpDatasetProfileDao extends DatabaseAccessLayer<DMPDatasetProfile, UUID> {
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
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.Content;
|
||||
import eu.eudat.data.entities.DMPDatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Service("dmpDatasetProfileDao")
|
||||
public class DmpDatasetProfileDaoImpl extends DatabaseAccess<DMPDatasetProfile> implements DmpDatasetProfileDao {
|
||||
@Autowired
|
||||
public DmpDatasetProfileDaoImpl(DatabaseService<DMPDatasetProfile> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile createOrUpdate(DMPDatasetProfile item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DMPDatasetProfile.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public CompletableFuture<DMPDatasetProfile> createOrUpdateAsync(DMPDatasetProfile item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DMPDatasetProfile item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPDatasetProfile> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.EmailConfirmationCriteria;
|
||||
import eu.eudat.data.entities.EmailConfirmation;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EmailConfirmationDao extends DatabaseAccessLayer<EmailConfirmation, UUID> {
|
||||
|
||||
QueryableList<EmailConfirmation> getWithCriteria(EmailConfirmationCriteria criteria);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.EmailConfirmationCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.EmailConfirmation;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Service("LoginConfirmationEmailDao")
|
||||
public class EmailConfirmationDaoImpl extends DatabaseAccess<EmailConfirmation> implements EmailConfirmationDao {
|
||||
|
||||
@Autowired
|
||||
public EmailConfirmationDaoImpl(DatabaseService<EmailConfirmation> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<EmailConfirmation> getWithCriteria(EmailConfirmationCriteria criteria) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmailConfirmation createOrUpdate(EmailConfirmation item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, EmailConfirmation.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<EmailConfirmation> createOrUpdateAsync(EmailConfirmation item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmailConfirmation find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(EmailConfirmation.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmailConfirmation find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(EmailConfirmation item) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<EmailConfirmation> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(EmailConfirmation.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.EntityDoi;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EntityDoiDao extends DatabaseAccessLayer<EntityDoi, UUID> {
|
||||
EntityDoi findFromDoi(String doi);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
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.EntityDoi;
|
||||
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("EntityDoiDao")
|
||||
public class EntityDoiDaoImpl extends DatabaseAccess<EntityDoi> implements EntityDoiDao {
|
||||
|
||||
@Autowired
|
||||
public EntityDoiDaoImpl(DatabaseService<EntityDoi> databaseService){
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityDoi createOrUpdate(EntityDoi item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, EntityDoi.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<EntityDoi> createOrUpdateAsync(EntityDoi item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDoi find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDoi findFromDoi(String doi) {
|
||||
return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("doi"), doi)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDoi find(UUID id, String hint) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(EntityDoi item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<EntityDoi> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(EntityDoi.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
||||
import eu.eudat.data.entities.ExternalDataset;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public interface ExternalDatasetDao extends DatabaseAccessLayer<ExternalDataset, UUID> {
|
||||
|
||||
QueryableList<ExternalDataset> getWithCriteria(ExternalDatasetCriteria criteria);
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.ExternalDataset;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
@Component("externalDatasetDao")
|
||||
public class ExternalDatasetDaoImpl extends DatabaseAccess<ExternalDataset> implements ExternalDatasetDao {
|
||||
|
||||
@Autowired
|
||||
public ExternalDatasetDaoImpl(DatabaseService<ExternalDataset> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<ExternalDataset> getWithCriteria(ExternalDatasetCriteria criteria) {
|
||||
QueryableList<ExternalDataset> query = this.getDatabaseService().getQueryable(ExternalDataset.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.or(
|
||||
builder.like(builder.upper(root.get("reference")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||
builder.equal(builder.upper(root.get("label")), criteria.getLike().toUpperCase())));
|
||||
if (criteria.getCreationUserId() != null)
|
||||
query.where((builder, root) -> builder.equal(root.join("creationUser").get("id"), criteria.getCreationUserId()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalDataset createOrUpdate(ExternalDataset item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, ExternalDataset.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalDataset find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(ExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ExternalDataset item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<ExternalDataset> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(ExternalDataset.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<ExternalDataset> createOrUpdateAsync(ExternalDataset item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalDataset find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.FileUpload;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FileUploadDao extends DatabaseAccessLayer<FileUpload, UUID> {
|
||||
List<FileUpload> getFileUploads(UUID entityId);
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
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.FileUpload;
|
||||
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("FileUploadDao")
|
||||
public class FileUploadDaoImpl extends DatabaseAccess<FileUpload> implements FileUploadDao {
|
||||
|
||||
@Autowired
|
||||
public FileUploadDaoImpl(DatabaseService<FileUpload> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileUpload createOrUpdate(FileUpload item) {
|
||||
return getDatabaseService().createOrUpdate(item, FileUpload.class);
|
||||
}
|
||||
//
|
||||
@Override
|
||||
public CompletableFuture<FileUpload> createOrUpdateAsync(FileUpload item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileUpload find(UUID id) {
|
||||
return getDatabaseService().getQueryable(FileUpload.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileUpload> getFileUploads(UUID entityId) {
|
||||
return this.getDatabaseService().getQueryable(FileUpload.class).where((builder, root) -> builder.equal(root.get("entityId"), entityId)).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileUpload find(UUID id, String hint) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(FileUpload item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<FileUpload> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(FileUpload.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.FunderCriteria;
|
||||
import eu.eudat.data.entities.Funder;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FunderDao extends DatabaseAccessLayer<Funder, UUID> {
|
||||
|
||||
QueryableList<Funder> getWithCritetia(FunderCriteria criteria);
|
||||
|
||||
QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserInfo principal);
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.FunderCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.Funder;
|
||||
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.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("funderDao")
|
||||
public class FunderDaoImpl extends DatabaseAccess<Funder> implements FunderDao {
|
||||
|
||||
@Autowired
|
||||
public FunderDaoImpl(DatabaseService<Funder> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Funder> getWithCritetia(FunderCriteria criteria) {
|
||||
QueryableList<Funder> query = getDatabaseService().getQueryable(Funder.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) ->
|
||||
builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||
builder.or(builder.like(builder.upper(root.get("definition")), "%" + criteria.getLike().toUpperCase() + "%"))));
|
||||
if (criteria.getReference() != null)
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("reference")), "%" + criteria.getReference().toUpperCase() + "%"));
|
||||
if (criteria.getExactReference() != null)
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("reference")), criteria.getExactReference().toUpperCase()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Funder.Status.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Funder> getAuthenticated(QueryableList<Funder> query, UserInfo principal) {
|
||||
query.where((builder, root) -> builder.equal(root.get("creationUser"), principal));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Funder createOrUpdate(Funder item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, Funder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Funder> createOrUpdateAsync(Funder item) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Funder find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(Funder.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Funder find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Funder item) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Funder> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Funder.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface GrantDao extends DatabaseAccessLayer<Grant, UUID> {
|
||||
|
||||
QueryableList<Grant> getWithCriteria(GrantCriteria criteria);
|
||||
|
||||
QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo principal);
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.types.grant.GrantStateType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import schemasMicrosoftComOfficeOffice.LeftDocument;
|
||||
|
||||
import jakarta.persistence.criteria.JoinType;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("grantDao")
|
||||
public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
|
||||
|
||||
@Autowired
|
||||
public GrantDaoImpl(DatabaseService<Grant> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Grant> getWithCriteria(GrantCriteria criteria) {
|
||||
QueryableList<Grant> query = getDatabaseService().getQueryable(Grant.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) ->
|
||||
builder.or(builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||
builder.or(builder.like(builder.upper(root.get("description")), "%" + criteria.getLike().toUpperCase() + "%"))));
|
||||
if (criteria.getPeriodEnd() != null)
|
||||
query.where((builder, root) -> builder.lessThan(root.get("enddate"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThan(root.get("startdate"), criteria.getPeriodStart()));
|
||||
if (criteria.getReference() != null)
|
||||
query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
|
||||
if (criteria.getExactReference() != null)
|
||||
query.where((builder, root) -> builder.like(root.get("reference"), criteria.getExactReference()));
|
||||
if (criteria.getGrantStateType() != null) {
|
||||
if (criteria.getGrantStateType().equals(GrantStateType.FINISHED.getValue()))
|
||||
query.where((builder, root) -> builder.lessThan(root.get("enddate"), new Date()));
|
||||
if (criteria.getGrantStateType().equals(GrantStateType.ONGOING.getValue()))
|
||||
query.where((builder, root) ->
|
||||
builder.or(builder.greaterThan(root.get("enddate"), new Date())
|
||||
, builder.isNull(root.get("enddate"))));
|
||||
}
|
||||
if (criteria.isPublic()) {
|
||||
query.where((builder, root) -> builder.equal(root.join("dmps").get("status"), DMP.DMPStatus.FINALISED.getValue())).distinct();
|
||||
}
|
||||
|
||||
if (criteria.isActive()) {
|
||||
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("status"), DMP.DMPStatus.DELETED.getValue())).distinct();
|
||||
}
|
||||
if (criteria.getFunderId() != null && !criteria.getFunderId().trim().isEmpty())
|
||||
query.where((builder, root) -> builder.equal(root.get("funder").get("id"), UUID.fromString(criteria.getFunderId())));
|
||||
if (criteria.getFunderReference() != null && !criteria.getFunderReference().isEmpty())
|
||||
query.where((builder, root) -> builder.or(builder.like(root.join("funder", JoinType.LEFT).get("reference"), "%" + criteria.getFunderReference())));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Grant.Status.DELETED.getValue()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grant createOrUpdate(Grant item) {
|
||||
return getDatabaseService().createOrUpdate(item, Grant.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grant find(UUID id) {
|
||||
return getDatabaseService().getQueryable(Grant.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Grant item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Grant> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Grant.class);
|
||||
}
|
||||
|
||||
public QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo principal) {
|
||||
query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), principal.getId())).distinct();
|
||||
return query;
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<Grant> createOrUpdateAsync(Grant item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Grant find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.InvitationCriteria;
|
||||
import eu.eudat.data.entities.Invitation;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public interface InvitationDao extends DatabaseAccessLayer<Invitation, UUID> {
|
||||
|
||||
QueryableList<Invitation> getWithCriteria(InvitationCriteria criteria);
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.InvitationCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.Invitation;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
@Service("invitationDao")
|
||||
public class InvitationDaoImpl extends DatabaseAccess<Invitation> implements InvitationDao {
|
||||
|
||||
@Autowired
|
||||
public InvitationDaoImpl(DatabaseService<Invitation> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Invitation> getWithCriteria(InvitationCriteria criteria) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Invitation createOrUpdate(Invitation item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, Invitation.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Invitation find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(Invitation.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Invitation item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<Invitation> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(Invitation.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<Invitation> createOrUpdateAsync(Invitation item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Invitation find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.LockCriteria;
|
||||
import eu.eudat.data.entities.Lock;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface LockDao extends DatabaseAccessLayer<Lock, UUID> {
|
||||
|
||||
QueryableList<Lock> getWithCriteria(LockCriteria criteria);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue