Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
2f8dbd58
Commit
2f8dbd58
authored
Nov 11, 2018
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: execute and *store* scheduled KPI executions
parent
51833dd1
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
55 additions
and
31 deletions
+55
-31
src/main/java/org/genesys2/server/api/v1/MeController.java
src/main/java/org/genesys2/server/api/v1/MeController.java
+1
-1
src/main/java/org/genesys2/server/model/kpi/BooleanDimension.java
.../java/org/genesys2/server/model/kpi/BooleanDimension.java
+5
-0
src/main/java/org/genesys2/server/model/kpi/Dimension.java
src/main/java/org/genesys2/server/model/kpi/Dimension.java
+2
-0
src/main/java/org/genesys2/server/model/kpi/DimensionKey.java
...main/java/org/genesys2/server/model/kpi/DimensionKey.java
+3
-3
src/main/java/org/genesys2/server/model/kpi/Execution.java
src/main/java/org/genesys2/server/model/kpi/Execution.java
+3
-3
src/main/java/org/genesys2/server/model/kpi/ExecutionDimension.java
...ava/org/genesys2/server/model/kpi/ExecutionDimension.java
+3
-3
src/main/java/org/genesys2/server/model/kpi/ExecutionRun.java
...main/java/org/genesys2/server/model/kpi/ExecutionRun.java
+3
-3
src/main/java/org/genesys2/server/model/kpi/FixedListDimension.java
...ava/org/genesys2/server/model/kpi/FixedListDimension.java
+3
-3
src/main/java/org/genesys2/server/model/kpi/JpaDimension.java
...main/java/org/genesys2/server/model/kpi/JpaDimension.java
+5
-0
src/main/java/org/genesys2/server/model/kpi/KPIParameter.java
...main/java/org/genesys2/server/model/kpi/KPIParameter.java
+3
-3
src/main/java/org/genesys2/server/model/kpi/NumericListDimension.java
...a/org/genesys2/server/model/kpi/NumericListDimension.java
+5
-0
src/main/java/org/genesys2/server/model/kpi/Observation.java
src/main/java/org/genesys2/server/model/kpi/Observation.java
+6
-6
src/main/java/org/genesys2/server/model/kpi/StringListDimension.java
...va/org/genesys2/server/model/kpi/StringListDimension.java
+6
-0
src/main/java/org/genesys2/server/service/impl/KPIServiceImpl.java
...java/org/genesys2/server/service/impl/KPIServiceImpl.java
+2
-1
src/main/java/org/genesys2/server/service/worker/KpiScheduledExecutor.java
.../genesys2/server/service/worker/KpiScheduledExecutor.java
+5
-5
No files found.
src/main/java/org/genesys2/server/api/v1/MeController.java
View file @
2f8dbd58
...
...
@@ -45,7 +45,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
(
"meApi1"
)
@RequestMapping
(
org
.
genesys2
.
server
.
api
.
v1
.
MeController
.
API_URL
)
@PreAuthorize
(
"isAuthenticated() &&
hasRole('USER'
)"
)
// Don't allow OAuth clients here
@PreAuthorize
(
"isAuthenticated() &&
(hasRole('USER') || hasRole('ADMINISTRATOR')
)"
)
// Don't allow OAuth clients here
@Api
(
tags
=
{
"me"
})
public
class
MeController
extends
ApiBaseController
{
...
...
src/main/java/org/genesys2/server/model/kpi/BooleanDimension.java
View file @
2f8dbd58
...
...
@@ -53,6 +53,11 @@ public class BooleanDimension extends Dimension<Boolean> {
@Column
private
int
mode
=
3
;
@Override
public
Class
<
Boolean
>
getTargetType
()
{
return
Boolean
.
class
;
}
@JsonIgnore
@Override
public
Set
<
Boolean
>
getValues
()
{
...
...
src/main/java/org/genesys2/server/model/kpi/Dimension.java
View file @
2f8dbd58
...
...
@@ -92,4 +92,6 @@ public abstract class Dimension<T> extends AuditedVersionedModel {
public
String
toString
()
{
return
"id="
+
getId
()
+
" name="
+
name
+
" title="
+
title
;
}
public
abstract
Class
<
T
>
getTargetType
();
}
src/main/java/org/genesys2/server/model/kpi/DimensionKey.java
View file @
2f8dbd58
...
...
@@ -4,15 +4,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.server.model.kpi
;
...
...
src/main/java/org/genesys2/server/model/kpi/Execution.java
View file @
2f8dbd58
...
...
@@ -4,15 +4,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.server.model.kpi
;
...
...
src/main/java/org/genesys2/server/model/kpi/ExecutionDimension.java
View file @
2f8dbd58
...
...
@@ -4,15 +4,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.server.model.kpi
;
...
...
src/main/java/org/genesys2/server/model/kpi/ExecutionRun.java
View file @
2f8dbd58
...
...
@@ -4,15 +4,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.server.model.kpi
;
...
...
src/main/java/org/genesys2/server/model/kpi/FixedListDimension.java
View file @
2f8dbd58
...
...
@@ -4,15 +4,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.server.model.kpi
;
...
...
src/main/java/org/genesys2/server/model/kpi/JpaDimension.java
View file @
2f8dbd58
...
...
@@ -42,6 +42,11 @@ public class JpaDimension extends Dimension<Object> {
@Column
(
name
=
"`condition`"
,
length
=
100
)
private
String
condition
;
@Override
public
Class
<
Object
>
getTargetType
()
{
return
Object
.
class
;
}
@JsonIgnore
@Override
public
Set
<
Object
>
getValues
()
{
...
...
src/main/java/org/genesys2/server/model/kpi/KPIParameter.java
View file @
2f8dbd58
...
...
@@ -4,15 +4,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.server.model.kpi
;
...
...
src/main/java/org/genesys2/server/model/kpi/NumericListDimension.java
View file @
2f8dbd58
...
...
@@ -47,6 +47,11 @@ public class NumericListDimension extends FixedListDimension<Number> {
@ElementCollection
()
@CollectionTable
(
name
=
"kpidimensionnumeric"
,
joinColumns
=
@JoinColumn
(
name
=
"dimensionId"
))
private
Set
<
Double
>
values
;
@Override
public
Class
<
Number
>
getTargetType
()
{
return
Number
.
class
;
}
public
void
setValues
(
Set
<
Number
>
list
)
{
if
(
list
==
null
)
{
...
...
src/main/java/org/genesys2/server/model/kpi/Observation.java
View file @
2f8dbd58
/*
*
* Copyright 201
4
Global Crop Diversity Trust
*
/*
* Copyright 201
8
Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
/
*/
package
org.genesys2.server.model.kpi
;
...
...
src/main/java/org/genesys2/server/model/kpi/StringListDimension.java
View file @
2f8dbd58
...
...
@@ -32,11 +32,17 @@ public class StringListDimension extends FixedListDimension<String> {
*
*/
private
static
final
long
serialVersionUID
=
7027186911390675241L
;
@Column
(
name
=
"listvalue"
,
nullable
=
false
)
@ElementCollection
()
@CollectionTable
(
name
=
"kpidimensionstring"
,
joinColumns
=
@JoinColumn
(
name
=
"dimensionId"
))
private
Set
<
String
>
values
=
new
HashSet
<
String
>();
@Override
public
Class
<
String
>
getTargetType
()
{
return
String
.
class
;
}
public
void
setValues
(
Set
<
String
>
values
)
{
this
.
values
=
values
;
}
...
...
src/main/java/org/genesys2/server/service/impl/KPIServiceImpl.java
View file @
2f8dbd58
...
...
@@ -28,6 +28,7 @@ import java.util.stream.Collectors;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
javax.persistence.Query
;
import
javax.persistence.TypedQuery
;
import
javax.validation.Valid
;
import
org.apache.commons.lang.ArrayUtils
;
...
...
@@ -220,7 +221,7 @@ public class KPIServiceImpl implements KPIService {
}
LOG
.
debug
(
paQuery
.
toString
());
Query
q
=
entityManager
.
createQuery
(
paQuery
.
toString
());
TypedQuery
<
T
>
q
=
entityManager
.
createQuery
(
paQuery
.
toString
(),
dim
.
getTargetType
());
return
new
HashSet
<
T
>(
q
.
getResultList
());
}
else
{
...
...
src/main/java/org/genesys2/server/service/worker/KpiScheduledExecutor.java
View file @
2f8dbd58
...
...
@@ -64,13 +64,13 @@ public class KpiScheduledExecutor {
Page
<
Execution
>
executions
;
do
{
executions
=
kpiService
.
listExecutions
(
new
PageRequest
(
page
,
chunkSize
));
for
(
Execution
ex
:
executions
.
getContent
())
{
for
(
Execution
ex
ecution
:
executions
.
getContent
())
{
try
{
LOG
.
info
(
"Started execution {} after {}ms"
,
ex
.
getName
(),
stopWatch
.
getTime
());
kpiService
.
execute
(
ex
);
LOG
.
info
(
"Execution {} successful after {}ms"
,
ex
.
getName
(),
stopWatch
.
getTime
());
LOG
.
info
(
"Started execution {} after {}ms"
,
ex
ecution
.
getName
(),
stopWatch
.
getTime
());
kpiService
.
execute
AndSave
(
execution
);
LOG
.
info
(
"Execution {} successful after {}ms"
,
ex
ecution
.
getName
(),
stopWatch
.
getTime
());
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Error running KPI Execution {}: {}"
,
ex
.
getName
(),
e
.
getMessage
(),
e
);
LOG
.
error
(
"Error running KPI Execution {}: {}"
,
ex
ecution
.
getName
(),
e
.
getMessage
(),
e
);
}
}
page
++;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment