Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dmp
OpenAIRE-EUDAT-DMP-service-pilot
Commits
e0c302e6
Commit
e0c302e6
authored
Oct 02, 2018
by
Ioannis Kalyvas
Browse files
no message
parent
f2bfd402
Pipeline
#2
failed with stages
Changes
148
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
dmp-backend/data/src/main/java/eu/eudat/data/entities/UserInfo.java
View file @
e0c302e6
package
eu.eudat.data.entities
;
import
eu.eudat.data.converters.DateToUTCConverter
;
import
eu.eudat.queryable.queryableentity.DataEntity
;
import
org.hibernate.annotations.GenericGenerator
;
import
org.hibernate.annotations.Type
;
import
javax.persistence.*
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.*
;
@Entity
...
...
@@ -44,10 +42,12 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
@Column
(
name
=
"created"
,
nullable
=
false
)
@Convert
(
converter
=
DateToUTCConverter
.
class
)
private
Date
created
=
null
;
@Column
(
name
=
"lastloggedin"
,
nullable
=
true
)
@Convert
(
converter
=
DateToUTCConverter
.
class
)
private
Date
lastloggedin
=
null
;
...
...
@@ -177,4 +177,10 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
public
UUID
getKeys
()
{
return
this
.
id
;
}
@Override
public
UserInfo
buildFromTuple
(
List
<
Tuple
>
tuple
,
String
base
)
{
this
.
id
=
(
UUID
)
tuple
.
get
(
0
).
get
(
base
.
isEmpty
()
?
"id"
:
base
+
"."
+
"id"
);
return
this
;
}
}
dmp-backend/data/src/main/java/eu/eudat/data/entities/UserRole.java
View file @
e0c302e6
...
...
@@ -4,6 +4,7 @@ import eu.eudat.queryable.queryableentity.DataEntity;
import
org.hibernate.annotations.GenericGenerator
;
import
javax.persistence.*
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -57,4 +58,10 @@ public class UserRole implements DataEntity<UserRole, UUID> {
public
UUID
getKeys
()
{
return
this
.
id
;
}
@Override
public
UserRole
buildFromTuple
(
List
<
Tuple
>
tuple
,
String
base
)
{
this
.
id
=
UUID
.
fromString
((
String
)
tuple
.
get
(
0
).
get
(
base
.
isEmpty
()
?
base
+
"."
+
"id"
:
"id"
));
return
this
;
}
}
dmp-backend/data/src/main/java/eu/eudat/data/entities/UserToken.java
View file @
e0c302e6
package
eu.eudat.data.entities
;
import
eu.eudat.data.converters.DateToUTCConverter
;
import
eu.eudat.queryable.queryableentity.DataEntity
;
import
javax.persistence.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -20,10 +22,12 @@ public class UserToken implements DataEntity<UserToken, UUID> {
private
UserInfo
user
;
@Column
(
name
=
"\"IssuedAt\""
,
nullable
=
false
)
@Convert
(
converter
=
DateToUTCConverter
.
class
)
private
Date
issuedAt
=
null
;
@Column
(
name
=
"\"ExpiresAt\""
,
nullable
=
false
)
@Convert
(
converter
=
DateToUTCConverter
.
class
)
private
Date
expiresAt
=
null
;
public
UUID
getToken
()
{
...
...
@@ -67,4 +71,10 @@ public class UserToken implements DataEntity<UserToken, UUID> {
public
UUID
getKeys
()
{
return
this
.
token
;
}
@Override
public
UserToken
buildFromTuple
(
List
<
Tuple
>
tuple
,
String
base
)
{
this
.
token
=
UUID
.
fromString
((
String
)
tuple
.
get
(
0
).
get
(
base
.
isEmpty
()
?
base
+
"."
+
"token"
:
"token"
));
return
this
;
}
}
dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/project/ProjectCriteriaRequest.java
View file @
e0c302e6
...
...
@@ -8,6 +8,16 @@ import eu.eudat.queryable.QueryableList;
import
java.util.UUID
;
public
class
ProjectCriteriaRequest
extends
Query
<
ProjectCriteria
,
Project
>
{
private
Integer
length
;
public
Integer
getLength
()
{
return
length
;
}
public
void
setLength
(
Integer
length
)
{
this
.
length
=
length
;
}
private
ProjectCriteriaRequest
()
{
}
...
...
dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dataset/DatasetPublicTableRequest.java
0 → 100644
View file @
e0c302e6
package
eu.eudat.data.query.items.table.dataset
;
import
eu.eudat.data.dao.criteria.DatasetPublicCriteria
;
import
eu.eudat.data.entities.Dataset
;
import
eu.eudat.data.query.definition.TableQuery
;
import
eu.eudat.queryable.QueryableList
;
import
eu.eudat.queryable.types.FieldSelectionType
;
import
eu.eudat.queryable.types.SelectionField
;
import
java.util.Arrays
;
import
java.util.UUID
;
/**
* Created by ikalyvas on 10/2/2018.
*/
public
class
DatasetPublicTableRequest
extends
TableQuery
<
DatasetPublicCriteria
,
Dataset
,
UUID
>
{
@Override
public
QueryableList
<
Dataset
>
applyCriteria
()
{
QueryableList
<
Dataset
>
query
=
this
.
getQuery
();
query
.
initSubQuery
(
String
.
class
).
where
((
builder
,
root
)
->
builder
.
equal
(
root
.
get
(
"dmp"
).
get
(
"version"
),
query
.<
String
>
subQueryMax
((
builder1
,
externalRoot
,
nestedRoot
)
->
builder1
.
equal
(
externalRoot
.
get
(
"dmp"
).
get
(
"groupId"
),
nestedRoot
.
get
(
"dmp"
).
get
(
"groupId"
)),
Arrays
.
asList
(
new
SelectionField
(
FieldSelectionType
.
COMPOSITE_FIELD
,
"dmp:version"
)),
String
.
class
)));
if
(
this
.
getCriteria
().
projects
!=
null
&&
!
this
.
getCriteria
().
projects
.
isEmpty
())
query
.
where
(((
builder
,
root
)
->
root
.
get
(
"dmp"
).
get
(
"project"
).
get
(
"id"
).
in
(
this
.
getCriteria
().
projects
)));
if
(
this
.
getCriteria
().
projectStatus
!=
null
)
query
.
where
(((
builder
,
root
)
->
builder
.
equal
(
root
.
get
(
"dmp"
).
get
(
"project"
).
get
(
"status"
),
this
.
getCriteria
().
projectStatus
.
getValue
())));
if
(
this
.
getCriteria
().
datasetProfile
!=
null
&&
!
this
.
getCriteria
().
datasetProfile
.
isEmpty
())
query
.
where
(((
builder
,
root
)
->
root
.
get
(
"profile"
).
get
(
"id"
).
in
(
this
.
getCriteria
().
datasetProfile
)));
if
(
this
.
getCriteria
().
dmpOrganisations
!=
null
&&
!
this
.
getCriteria
().
dmpOrganisations
.
isEmpty
())
query
.
where
(((
builder
,
root
)
->
root
.
join
(
"dmp"
).
join
(
"organisations"
).
get
(
"reference"
).
in
(
this
.
getCriteria
().
dmpOrganisations
)));
return
query
;
}
@Override
public
QueryableList
<
Dataset
>
applyPaging
(
QueryableList
<
Dataset
>
items
)
{
return
null
;
}
}
dmp-backend/queryable/src/main/java/eu/eudat/queryable/jpa/hibernatequeryablelist/QueryableHibernateList.java
View file @
e0c302e6
...
...
@@ -2,25 +2,27 @@ package eu.eudat.queryable.jpa.hibernatequeryablelist;
import
eu.eudat.queryable.QueryableList
;
import
eu.eudat.queryable.exceptions.NotSingleResultException
;
import
eu.eudat.queryable.jpa.predicates.*
;
import
eu.eudat.queryable.jpa.predicates.NestedQuerySinglePredicate
;
import
eu.eudat.queryable.jpa.predicates.OrderByPredicate
;
import
eu.eudat.queryable.jpa.predicates.SelectPredicate
;
import
eu.eudat.queryable.jpa.predicates.SinglePredicate
;
import
eu.eudat.queryable.queryableentity.DataEntity
;
import
eu.eudat.queryable.types.FieldSelectionType
;
import
eu.eudat.queryable.types.SelectionField
;
import
org.springframework.scheduling.annotation.Async
;
import
javax.persistence.EntityManager
;
import
javax.persistence.Tuple
;
import
javax.persistence.TypedQuery
;
import
javax.persistence.criteria.*
;
import
java.util.Arrays
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.stream.Collectors
;
public
class
QueryableHibernateList
<
T
extends
DataEntity
>
implements
QueryableList
<
T
>
{
private
EntityManager
manager
;
private
CriteriaQuery
<
T
>
query
;
private
CriteriaQuery
query
;
private
Class
<
T
>
tClass
;
private
Root
<
T
>
root
;
private
Root
<
T
>
nestedQueryRoot
;
...
...
@@ -57,15 +59,32 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
}
private
QueryableList
<
T
>
selectFields
()
{
List
<
Selection
>
rootFields
=
fields
.
stream
().
map
(
field
->
root
.
get
(
field
)).
collect
(
Collectors
.
toList
());
this
.
query
.
select
(
this
.
manager
.
getCriteriaBuilder
().
construct
(
tClass
,
rootFields
.
toArray
(
new
Selection
[
rootFields
.
size
()])));
List
<
Selection
>
rootFields
=
fields
.
stream
().
map
(
field
->
this
.
convertFieldToPath
(
field
)).
collect
(
Collectors
.
toList
());
this
.
query
.
select
(
this
.
manager
.
getCriteriaBuilder
().
tuple
(
rootFields
.
toArray
(
new
Selection
[
rootFields
.
size
()])));
return
this
;
}
private
Path
convertFieldToPath
(
String
field
)
{
if
(!
field
.
contains
(
"."
))
{
Path
path
=
this
.
root
.
get
(
field
);
path
.
alias
(
field
);
return
path
;
}
else
{
String
[]
fields
=
field
.
split
(
"\\."
);
Path
path
=
this
.
root
.
get
(
fields
[
0
]);
Join
join
=
null
;
path
.
alias
(
fields
[
0
]);
for
(
int
i
=
1
;
i
<
fields
.
length
;
i
++)
{
join
=
join
!=
null
?
join
.
join
(
fields
[
i
-
1
],
JoinType
.
LEFT
)
:
this
.
root
.
join
(
fields
[
i
-
1
],
JoinType
.
LEFT
)
;
path
=
join
.
get
(
fields
[
i
]);
path
.
alias
(
String
.
join
(
"."
,
Arrays
.
asList
(
fields
).
subList
(
0
,
i
+
1
)));
}
return
path
;
}
}
public
QueryableHibernateList
<
T
>
setEntity
(
Class
<
T
>
type
)
{
CriteriaBuilder
builder
=
this
.
manager
.
getCriteriaBuilder
();
this
.
query
=
builder
.
createQuery
(
type
);
this
.
root
=
this
.
query
.
from
(
this
.
tClass
);
return
this
;
}
...
...
@@ -125,6 +144,7 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
return
this
.
manager
.
createQuery
(
criteriaQuery
).
getSingleResult
();
}
@Async
public
CompletableFuture
<
Long
>
countAsync
()
{
CriteriaBuilder
criteriaBuilder
=
this
.
manager
.
getCriteriaBuilder
();
CriteriaQuery
<
Long
>
criteriaQuery
=
criteriaBuilder
.
createQuery
(
Long
.
class
);
...
...
@@ -169,10 +189,33 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
}
public
List
<
T
>
toList
()
{
CriteriaBuilder
builder
=
this
.
manager
.
getCriteriaBuilder
();
if
(!
this
.
fields
.
isEmpty
())
this
.
query
=
builder
.
createTupleQuery
();
else
this
.
query
=
builder
.
createQuery
(
this
.
tClass
);
this
.
root
=
this
.
query
.
from
(
this
.
tClass
);
this
.
query
.
where
(
this
.
generateWherePredicates
(
this
.
singlePredicates
,
this
.
root
,
this
.
nestedPredicates
,
this
.
nestedQueryRoot
));
if
(!
this
.
orderings
.
isEmpty
())
this
.
query
.
orderBy
(
this
.
generateOrderPredicates
(
this
.
orderings
,
this
.
root
));
if
(
this
.
fields
!=
null
&&
!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
if
(!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
if
(
distinct
)
this
.
query
.
distinct
(
true
);
if
(!
this
.
fields
.
isEmpty
())
return
this
.
toListWithFields
();
else
return
this
.
toListWithOutFields
();
}
private
List
<
T
>
toListWithFields
()
{
List
<
Tuple
>
results
=
this
.
manager
.
createQuery
(
query
).
getResultList
();
Map
<
Object
,
List
<
Tuple
>>
groupedResults
=
results
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
x
->
x
.
get
(
"id"
)));
return
results
.
stream
().
map
(
x
->
{
try
{
return
(
T
)
this
.
tClass
.
newInstance
().
buildFromTuple
(
groupedResults
.
get
(
x
.
get
(
"id"
)),
""
);
}
catch
(
InstantiationException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}).
collect
(
Collectors
.
toList
());
}
private
List
<
T
>
toListWithOutFields
()
{
TypedQuery
<
T
>
typedQuery
=
this
.
manager
.
createQuery
(
this
.
query
);
if
(
this
.
offset
!=
null
)
typedQuery
.
setFirstResult
(
this
.
offset
);
if
(
this
.
length
!=
null
)
typedQuery
.
setMaxResults
(
this
.
length
);
...
...
@@ -183,11 +226,35 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
return
typedQuery
.
getResultList
();
}
@Async
public
CompletableFuture
<
List
<
T
>>
toListAsync
()
{
CriteriaBuilder
builder
=
this
.
manager
.
getCriteriaBuilder
();
if
(!
this
.
fields
.
isEmpty
())
this
.
query
=
builder
.
createTupleQuery
();
else
this
.
query
=
builder
.
createQuery
(
this
.
tClass
);
this
.
root
=
this
.
query
.
from
(
this
.
tClass
);
this
.
query
.
where
(
this
.
generateWherePredicates
(
this
.
singlePredicates
,
this
.
root
,
this
.
nestedPredicates
,
this
.
nestedQueryRoot
));
if
(!
this
.
orderings
.
isEmpty
())
this
.
query
.
orderBy
(
this
.
generateOrderPredicates
(
this
.
orderings
,
this
.
root
));
if
(
this
.
fields
!=
null
&&
!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
if
(!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
if
(
distinct
)
this
.
query
.
distinct
(
true
);
if
(!
this
.
fields
.
isEmpty
())
return
this
.
toListAsyncWithFields
();
else
return
this
.
toListAsyncWithOutFields
();
}
private
CompletableFuture
<
List
<
T
>>
toListAsyncWithFields
()
{
List
<
Tuple
>
results
=
this
.
manager
.
createQuery
(
query
).
getResultList
();
Map
<
Object
,
List
<
Tuple
>>
groupedResults
=
results
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
x
->
x
.
get
(
"id"
)));
return
CompletableFuture
.
supplyAsync
(()
->
results
.
stream
().
map
(
x
->
{
try
{
return
(
T
)
this
.
tClass
.
newInstance
().
buildFromTuple
(
groupedResults
.
get
(
x
.
get
(
"id"
)),
""
);
}
catch
(
InstantiationException
|
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}).
collect
(
Collectors
.
toList
()));
}
private
CompletableFuture
<
List
<
T
>>
toListAsyncWithOutFields
()
{
TypedQuery
<
T
>
typedQuery
=
this
.
manager
.
createQuery
(
this
.
query
);
if
(
this
.
offset
!=
null
)
typedQuery
.
setFirstResult
(
this
.
offset
);
if
(
this
.
length
!=
null
)
typedQuery
.
setMaxResults
(
this
.
length
);
...
...
@@ -201,17 +268,26 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
}
public
T
getSingle
()
{
CriteriaBuilder
builder
=
this
.
manager
.
getCriteriaBuilder
();
if
(!
this
.
fields
.
isEmpty
())
this
.
query
=
builder
.
createTupleQuery
();
else
this
.
query
=
builder
.
createQuery
(
this
.
tClass
);
this
.
root
=
this
.
query
.
from
(
this
.
tClass
);
this
.
query
.
where
(
this
.
generateWherePredicates
(
this
.
singlePredicates
,
this
.
root
,
this
.
nestedPredicates
,
this
.
nestedQueryRoot
));
if
(
this
.
fields
!=
null
&&
!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
if
(!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
TypedQuery
<
T
>
typedQuery
=
this
.
manager
.
createQuery
(
this
.
query
);
if
(
this
.
hint
!=
null
)
typedQuery
.
setHint
(
"javax.persistence.fetchgraph"
,
this
.
manager
.
getEntityGraph
(
this
.
hint
));
return
typedQuery
.
getSingleResult
();
}
@Async
public
CompletableFuture
<
T
>
getSingleAsync
()
{
CriteriaBuilder
builder
=
this
.
manager
.
getCriteriaBuilder
();
if
(!
this
.
fields
.
isEmpty
())
this
.
query
=
builder
.
createTupleQuery
();
else
this
.
query
=
builder
.
createQuery
(
this
.
tClass
);
this
.
root
=
this
.
query
.
from
(
this
.
tClass
);
this
.
query
.
where
(
this
.
generateWherePredicates
(
this
.
singlePredicates
,
this
.
root
,
this
.
nestedPredicates
,
this
.
nestedQueryRoot
));
if
(
this
.
fields
!=
null
&&
!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
if
(!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
TypedQuery
<
T
>
typedQuery
=
this
.
manager
.
createQuery
(
this
.
query
);
if
(
this
.
hint
!=
null
)
typedQuery
.
setHint
(
"javax.persistence.fetchgraph"
,
this
.
manager
.
getEntityGraph
(
this
.
hint
));
...
...
@@ -219,8 +295,12 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
}
public
T
getSingleOrDefault
()
{
CriteriaBuilder
builder
=
this
.
manager
.
getCriteriaBuilder
();
if
(!
this
.
fields
.
isEmpty
())
this
.
query
=
builder
.
createTupleQuery
();
else
this
.
query
=
builder
.
createQuery
(
this
.
tClass
);
this
.
root
=
this
.
query
.
from
(
this
.
tClass
);
this
.
query
.
where
(
this
.
generateWherePredicates
(
this
.
singlePredicates
,
this
.
root
,
this
.
nestedPredicates
,
this
.
nestedQueryRoot
));
if
(
this
.
fields
!=
null
&&
!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
if
(!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
TypedQuery
<
T
>
typedQuery
=
this
.
manager
.
createQuery
(
this
.
query
);
if
(
this
.
hint
!=
null
)
typedQuery
.
setHint
(
"javax.persistence.fetchgraph"
,
this
.
manager
.
getEntityGraph
(
this
.
hint
));
...
...
@@ -230,9 +310,14 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
else
throw
new
NotSingleResultException
(
"Query returned more than one items"
);
}
@Async
public
CompletableFuture
<
T
>
getSingleOrDefaultAsync
()
{
CriteriaBuilder
builder
=
this
.
manager
.
getCriteriaBuilder
();
if
(!
this
.
fields
.
isEmpty
())
this
.
query
=
builder
.
createTupleQuery
();
else
this
.
query
=
builder
.
createQuery
(
this
.
tClass
);
this
.
root
=
this
.
query
.
from
(
this
.
tClass
);
this
.
query
.
where
(
this
.
generateWherePredicates
(
this
.
singlePredicates
,
this
.
root
,
this
.
nestedPredicates
,
this
.
nestedQueryRoot
));
if
(
this
.
fields
!=
null
&&
!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
if
(!
this
.
fields
.
isEmpty
())
this
.
selectFields
();
TypedQuery
<
T
>
typedQuery
=
this
.
manager
.
createQuery
(
this
.
query
);
if
(
this
.
hint
!=
null
)
typedQuery
.
setHint
(
"javax.persistence.fetchgraph"
,
this
.
manager
.
getEntityGraph
(
this
.
hint
));
...
...
dmp-backend/queryable/src/main/java/eu/eudat/queryable/queryableentity/DataEntity.java
View file @
e0c302e6
package
eu.eudat.queryable.queryableentity
;
import
javax.persistence.Tuple
;
import
java.util.List
;
public
interface
DataEntity
<
T
,
K
>
{
void
update
(
T
entity
);
K
getKeys
();
T
buildFromTuple
(
List
<
Tuple
>
tuple
,
String
base
);
}
dmp-backend/web/src/main/java/eu/eudat/EuDatApplication.java
View file @
e0c302e6
...
...
@@ -6,8 +6,10 @@ import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.web.support.SpringBootServletInitializer
;
import
org.springframework.scheduling.annotation.EnableAsync
;
@SpringBootApplication
@EnableAsync
public
class
EuDatApplication
extends
SpringBootServletInitializer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EuDatApplication
.
class
);
...
...
dmp-backend/web/src/main/java/eu/eudat/configurations/DevelDatabaseConfiguration.java
View file @
e0c302e6
...
...
@@ -2,10 +2,9 @@ package eu.eudat.configurations;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Profile
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.*
;
import
org.springframework.core.env.Environment
;
import
org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor
;
import
org.springframework.jdbc.datasource.DriverManagerDataSource
;
...
...
@@ -37,25 +36,26 @@ public class DevelDatabaseConfiguration {
JpaVendorAdapter
vendorAdapter
=
new
HibernateJpaVendorAdapter
();
em
.
setJpaVendorAdapter
(
vendorAdapter
);
em
.
setJpaProperties
(
additionalProperties
());
return
em
;
}
@Bean
@Primary
@ConfigurationProperties
(
prefix
=
"spring.datasource"
)
public
DataSource
dataSource
()
{
DriverManagerDataSource
dataSource
=
new
DriverManagerDataSource
();
dataSource
.
setDriverClassName
(
env
.
getProperty
(
"database.driver-class-name"
));
dataSource
.
setUrl
(
env
.
getProperty
(
"devel.database.url"
));
dataSource
.
setUsername
(
env
.
getProperty
(
"devel.database.username"
));
dataSource
.
setPassword
(
env
.
getProperty
(
"devel.database.password"
));
return
dataSource
;
return
DataSourceBuilder
.
create
()
.
username
(
env
.
getProperty
(
"devel.database.username"
))
.
password
(
env
.
getProperty
(
"devel.database.password"
))
.
url
(
env
.
getProperty
(
"devel.database.url"
))
.
driverClassName
(
env
.
getProperty
(
"database.driver-class-name"
))
.
build
();
}
@Bean
public
PlatformTransactionManager
transactionManager
(
EntityManagerFactory
emf
)
{
JpaTransactionManager
transactionManager
=
new
JpaTransactionManager
();
transactionManager
.
setEntityManagerFactory
(
emf
);
return
transactionManager
;
}
...
...
@@ -69,6 +69,10 @@ public class DevelDatabaseConfiguration {
properties
.
setProperty
(
"hibernate.dialect"
,
"org.hibernate.dialect.PostgreSQL92Dialect"
);
properties
.
setProperty
(
"hibernate.show_sql"
,
"true"
);
properties
.
setProperty
(
"hibernate.temp.use_jdbc_metadata_defaults"
,
"false"
);
properties
.
setProperty
(
"hibernate.c3p0.maxPoolSize"
,
"70"
);
properties
.
setProperty
(
"hibernate.c3p0.timeout"
,
"5000"
);
properties
.
setProperty
(
"hibernate.connection.release_mode"
,
"after_transaction"
);
//properties.setProperty("hibernate.connection.provider_class", "org.hibernate.c3p0.internal.C3P0ConnectionProvider");
return
properties
;
}
}
\ No newline at end of file
dmp-backend/web/src/main/java/eu/eudat/configurations/ExecutorServiceConfig.java
0 → 100644
View file @
e0c302e6
package
eu.eudat.configurations
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.task.TaskExecutor
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
/**
* Created by ikalyvas on 9/26/2018.
*/
@Configuration
public
class
ExecutorServiceConfig
{
@Bean
public
Executor
asyncExecutor
()
{
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
executor
.
setCorePoolSize
(
2
);
executor
.
setMaxPoolSize
(
2
);
executor
.
setQueueCapacity
(
500
);
executor
.
setThreadNamePrefix
(
"Rules-"
);
executor
.
initialize
();
return
executor
;
}
}
\ No newline at end of file
dmp-backend/web/src/main/java/eu/eudat/controllers/Admin.java
View file @
e0c302e6
package
eu.eudat.controllers
;
import
eu.eudat.core.logger.Logger
;
import
eu.eudat.logic.managers.AdminManager
;
import
eu.eudat.logic.managers.UserManager
;
import
eu.eudat.logic.security.claims.ClaimedAuthorities
;
import
eu.eudat.logic.services.ApiContext
;
import
eu.eudat.logic.services.helpers.LoggerService
;
import
eu.eudat.models.data.admin.composite.DatasetProfile
;
import
eu.eudat.models.data.helpers.responses.ResponseItem
;
import
eu.eudat.models.data.security.Principal
;
import
eu.eudat.models.data.user.composite.PagedDatasetProfile
;
import
eu.eudat.types.ApiMessageCode
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -24,13 +28,14 @@ import static eu.eudat.types.Authorities.ADMIN;
public
class
Admin
extends
BaseController
{
@Autowired
public
Admin
(
ApiContext
apiContext
)
{
public
Admin
(
ApiContext
apiContext
,
Logger
logger
)
{
super
(
apiContext
);
}
@Transactional
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/admin/addDmp"
},
consumes
=
"application/json"
,
produces
=
"application/json"
)
public
ResponseEntity
<
Object
>
addDmp
(
@Valid
@RequestBody
DatasetProfile
profile
,
@ClaimedAuthorities
(
claims
=
{
ADMIN
})
Principal
principal
)
{
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
eu
.
eudat
.
data
.
entities
.
DatasetProfile
modelDefinition
=
AdminManager
.
generateViewStyleDefinition
(
profile
,
getApiContext
());
this
.
getApiContext
().
getOperationsContext
().
getDatabaseRepository
().
getDatasetProfileDao
().
createOrUpdate
(
modelDefinition
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
modelDefinition
.
getId
());
...
...
@@ -39,6 +44,7 @@ public class Admin extends BaseController {
@Transactional
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/admin/addDmp/{id}"
},
consumes
=
"application/json"
,
produces
=
"application/json"
)
public
ResponseEntity
<
ResponseItem
<
UUID
>>
updateDmp
(
@PathVariable
String
id
,
@RequestBody
DatasetProfile
profile
,
@ClaimedAuthorities
(
claims
=
{
ADMIN
})
Principal
principal
)
{
//this.getLoggerService().info(principal, "Admin Edited Dataset Profile");
eu
.
eudat
.
data
.
entities
.
DatasetProfile
modelDefinition
=
AdminManager
.
generateViewStyleDefinition
(
profile
,
getApiContext
());
eu
.
eudat
.
data
.
entities
.
DatasetProfile
datasetprofile
=
this
.
getApiContext
().
getOperationsContext
().
getDatabaseRepository
().
getDatasetProfileDao
().
find
(
UUID
.
fromString
(
id
));
...
...
@@ -50,9 +56,20 @@ public class Admin extends BaseController {
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
{
"/admin/get/{id}"
},
produces
=
"application/json"
)
public
ResponseEntity
<
ResponseItem
<
DatasetProfile
>>
get
(
@PathVariable
String
id
,
@ClaimedAuthorities
(
claims
=
{
ADMIN
})
Principal
principal
)
{
//this.getLoggerService().info(principal, "Admin Open Dataset Profile");
eu
.
eudat
.
data
.
entities
.
DatasetProfile
profile
=
this
.
getApiContext
().
getOperationsContext
().
getDatabaseRepository
().
getDatasetProfileDao
().
find
(
UUID
.
fromString
(
id
));
eu
.
eudat
.
models
.
data
.
admin
.
composite
.
DatasetProfile
datasetprofile
=
AdminManager
.
generateDatasetProfileModel
(
profile
);
datasetprofile
.
setLabel
(
profile
.
getLabel
());
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
new
ResponseItem
<
DatasetProfile
>().
status
(
ApiMessageCode
.
NO_MESSAGE
).
payload
(
datasetprofile
));
}
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/admin/preview"
},
consumes
=
"application/json"
,
produces
=
"application/json"
)
public
ResponseEntity
<
ResponseItem
<
PagedDatasetProfile
>>
getPreview
(
@RequestBody
DatasetProfile
profile
,
@ClaimedAuthorities
(
claims
=
{
ADMIN
})
Principal
principal
)
{
//this.getLoggerService().info(principal, "Admin Previewed Dataset Profile");
eu
.
eudat
.
data
.
entities
.
DatasetProfile
modelDefinition
=
AdminManager
.
generateViewStyleDefinition
(
profile
,
getApiContext
());
eu
.
eudat
.
models
.
data
.
user
.
composite
.
DatasetProfile
datasetProfile
=
UserManager
.
generateDatasetProfileModel
(
modelDefinition
);
PagedDatasetProfile
pagedDatasetProfile
=
new
PagedDatasetProfile
();
pagedDatasetProfile
.
buildPagedDatasetProfile
(
datasetProfile
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
new
ResponseItem
<
PagedDatasetProfile
>().
status
(
ApiMessageCode
.
NO_MESSAGE
).
payload
(
pagedDatasetProfile
));
}
}
dmp-backend/web/src/main/java/eu/eudat/controllers/BaseController.java
View file @
e0c302e6
package
eu.eudat.controllers
;
import
eu.eudat.core.logger.Logger
;
import
eu.eudat.logic.services.ApiContext
;
import
eu.eudat.logic.services.helpers.LoggerService
;
import
eu.eudat.models.validators.*
;
import
org.springframework.beans.factory.annotation.Autowired
;