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
d072460b
Commit
d072460b
authored
Aug 01, 2014
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduced ExecutionRun to group Observations
parent
f11aded1
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
30 deletions
+112
-30
src/main/java/org/genesys2/server/model/kpi/Execution.java
src/main/java/org/genesys2/server/model/kpi/Execution.java
+1
-0
src/main/java/org/genesys2/server/model/kpi/ExecutionRun.java
...main/java/org/genesys2/server/model/kpi/ExecutionRun.java
+59
-0
src/main/java/org/genesys2/server/model/kpi/Observation.java
src/main/java/org/genesys2/server/model/kpi/Observation.java
+7
-25
src/main/java/org/genesys2/server/persistence/domain/kpi/ExecutionRunRepository.java
...server/persistence/domain/kpi/ExecutionRunRepository.java
+30
-0
src/main/java/org/genesys2/server/persistence/domain/kpi/ObservationRepository.java
.../server/persistence/domain/kpi/ObservationRepository.java
+3
-2
src/main/java/org/genesys2/server/service/impl/KPIServiceImpl.java
...java/org/genesys2/server/service/impl/KPIServiceImpl.java
+12
-2
src/test/java/org/genesys2/server/service/impl/KPIServiceTest.java
...java/org/genesys2/server/service/impl/KPIServiceTest.java
+0
-1
No files found.
src/main/java/org/genesys2/server/model/kpi/Execution.java
View file @
d072460b
...
...
@@ -144,4 +144,5 @@ public class Execution extends VersionedAuditedModel {
public
void
setTitle
(
String
title
)
{
this
.
title
=
title
;
}
}
src/main/java/org/genesys2/server/model/kpi/ExecutionRun.java
0 → 100644
View file @
d072460b
/**
* Copyright 2014 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
;
import
java.util.Date
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.ManyToOne
;
import
javax.persistence.Table
;
import
javax.persistence.Temporal
;
import
javax.persistence.TemporalType
;
import
org.genesys2.server.model.BusinessModel
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
@Entity
@Table
(
name
=
"kpiexecutionrun"
)
public
class
ExecutionRun
extends
BusinessModel
{
@Column
(
nullable
=
false
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
timestamp
=
new
Date
();
@JsonIgnore
@ManyToOne
(
cascade
=
{},
optional
=
false
)
private
Execution
execution
;
public
Date
getTimestamp
()
{
return
timestamp
;
}
public
void
setTimestamp
(
Date
timestamp
)
{
this
.
timestamp
=
timestamp
;
}
public
Execution
getExecution
()
{
return
execution
;
}
public
void
setExecution
(
Execution
execution
)
{
this
.
execution
=
execution
;
}
}
src/main/java/org/genesys2/server/model/kpi/Observation.java
View file @
d072460b
...
...
@@ -16,7 +16,6 @@
package
org.genesys2.server.model.kpi
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.Set
;
...
...
@@ -29,13 +28,9 @@ import javax.persistence.ManyToMany;
import
javax.persistence.ManyToOne
;
import
javax.persistence.PrePersist
;
import
javax.persistence.Table
;
import
javax.persistence.Temporal
;
import
javax.persistence.TemporalType
;
import
org.genesys2.server.model.BusinessModel
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
/**
* Holds results of {@link Execution} run.
*/
...
...
@@ -43,17 +38,12 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
@Table
(
name
=
"kpiobservation"
)
public
class
Observation
extends
BusinessModel
{
@Column
(
nullable
=
false
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
timestamp
=
new
Date
();
@Column
(
name
=
"`value`"
)
private
double
value
;
@JsonIgnore
@ManyToOne
(
cascade
=
{},
fetch
=
FetchType
.
LAZY
,
optional
=
false
)
@JoinColumn
(
name
=
"executionId"
)
private
Execution
executio
n
;
@JoinColumn
(
name
=
"execution
Run
Id"
)
private
Execution
Run
executionRu
n
;
@ManyToMany
(
fetch
=
FetchType
.
LAZY
)
@JoinTable
(
name
=
"kpiobservationdimension"
,
joinColumns
=
@JoinColumn
(
name
=
"observationId"
),
inverseJoinColumns
=
@JoinColumn
(
name
=
"dimensionKeyId"
))
...
...
@@ -91,24 +81,16 @@ public class Observation extends BusinessModel {
this
.
dimensionCount
=
dimensionCount
;
}
public
Date
getTimestamp
()
{
return
timestamp
;
}
public
void
setTimestamp
(
Date
timestamp
)
{
this
.
timestamp
=
timestamp
;
}
public
Execution
getExecution
()
{
return
execution
;
public
ExecutionRun
getExecutionRun
()
{
return
executionRun
;
}
public
void
setExecution
(
Execution
executio
n
)
{
this
.
execution
=
executio
n
;
public
void
setExecution
Run
(
ExecutionRun
executionRu
n
)
{
this
.
execution
Run
=
executionRu
n
;
}
@Override
public
String
toString
()
{
return
execution
.
getName
()
+
"="
+
value
+
" D="
+
dimensions
+
" T="
+
timestamp
.
getTime
()
;
return
"value ="
+
value
+
" D="
+
dimensions
;
}
}
src/main/java/org/genesys2/server/persistence/domain/kpi/ExecutionRunRepository.java
0 → 100644
View file @
d072460b
/**
* Copyright 2014 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.persistence.domain.kpi
;
import
java.util.List
;
import
org.genesys2.server.model.kpi.Execution
;
import
org.genesys2.server.model.kpi.ExecutionRun
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
ExecutionRunRepository
extends
JpaRepository
<
ExecutionRun
,
Long
>
{
List
<
ExecutionRun
>
findByExecution
(
Execution
execution
,
Pageable
pageable
);
}
src/main/java/org/genesys2/server/persistence/domain/kpi/ObservationRepository.java
View file @
d072460b
...
...
@@ -28,13 +28,14 @@ import org.springframework.data.jpa.repository.Query;
public
interface
ObservationRepository
extends
JpaRepository
<
Observation
,
Long
>,
ObservationCustomRepository
{
@Query
(
"select o from Observation o where o.executionRun.execution=?1"
)
List
<
Observation
>
findByExecution
(
Execution
execution
,
Pageable
page
);
@Query
(
"select o from Observation o where o.execution
=?1 and ?2 member of o.dimensions order by o
.timestamp desc"
)
@Query
(
"select o from Observation o where o.execution
Run.execution=?1 and ?2 member of o.dimensions order by o.executionRun
.timestamp desc"
)
List
<
Observation
>
listObservationsByDimensionKey
(
Execution
execution
,
DimensionKey
next
,
Pageable
page
);
@Modifying
@Query
(
"delete from Observation o where o.execution=?1"
)
@Query
(
"delete from Observation o where o.execution
Run.execution
=?1"
)
void
deleteByExecution
(
Execution
execution
);
}
src/main/java/org/genesys2/server/service/impl/KPIServiceImpl.java
View file @
d072460b
...
...
@@ -17,6 +17,7 @@
package
org.genesys2.server.service.impl
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -32,12 +33,14 @@ import org.apache.commons.logging.LogFactory;
import
org.genesys2.server.model.kpi.Dimension
;
import
org.genesys2.server.model.kpi.DimensionKey
;
import
org.genesys2.server.model.kpi.Execution
;
import
org.genesys2.server.model.kpi.ExecutionRun
;
import
org.genesys2.server.model.kpi.JpaDimension
;
import
org.genesys2.server.model.kpi.KPIParameter
;
import
org.genesys2.server.model.kpi.Observation
;
import
org.genesys2.server.persistence.domain.kpi.DimensionKeyRepository
;
import
org.genesys2.server.persistence.domain.kpi.DimensionRepository
;
import
org.genesys2.server.persistence.domain.kpi.ExecutionRepository
;
import
org.genesys2.server.persistence.domain.kpi.ExecutionRunRepository
;
import
org.genesys2.server.persistence.domain.kpi.KPIParameterRepository
;
import
org.genesys2.server.persistence.domain.kpi.ObservationRepository
;
import
org.genesys2.server.service.KPIService
;
...
...
@@ -72,6 +75,9 @@ public class KPIServiceImpl implements KPIService {
@Autowired
private
DimensionKeyRepository
dimensionKeyRepository
;
@Autowired
private
ExecutionRunRepository
executionRunRepository
;
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasPermission(#parameter, 'ADMINISTRATION')"
)
@Override
@Transactional
...
...
@@ -221,8 +227,13 @@ public class KPIServiceImpl implements KPIService {
@Override
@Transactional
public
List
<
Observation
>
save
(
Execution
execution
,
List
<
Observation
>
observations
)
{
ExecutionRun
executionRun
=
new
ExecutionRun
();
executionRun
.
setExecution
(
execution
);
executionRun
.
setTimestamp
(
new
Date
());
executionRunRepository
.
save
(
executionRun
);
for
(
Observation
obs
:
observations
)
{
obs
.
setExecution
(
executio
n
);
obs
.
setExecution
Run
(
executionRu
n
);
Set
<
DimensionKey
>
dims
=
new
HashSet
<
DimensionKey
>();
for
(
DimensionKey
dk
:
obs
.
getDimensions
())
{
DimensionKey
existing
=
dimensionKeyRepository
.
findByNameAndValue
(
dk
.
getName
(),
dk
.
getValue
());
...
...
@@ -271,7 +282,6 @@ public class KPIServiceImpl implements KPIService {
Observation
observation
=
new
Observation
();
observation
.
setValue
(
res
);
observation
.
setExecution
(
paramExec
);
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
String
name
=
paramExec
.
getDimension
(
i
).
getName
();
String
value
=
array
[
i
].
toString
();
...
...
src/test/java/org/genesys2/server/service/impl/KPIServiceTest.java
View file @
d072460b
...
...
@@ -230,7 +230,6 @@ public class KPIServiceTest {
}
Observation
observation
=
new
Observation
();
observation
.
setExecution
(
paramExec
);
observation
.
setValue
((
Long
)
res
);
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++)
{
DimensionKey
dk
=
new
DimensionKey
();
...
...
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