Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
maarchRM
Commits
c4c48dc1
Unverified
Commit
c4c48dc1
authored
Aug 04, 2020
by
Jerome Boucher
Browse files
fix/14312 : add count on lifecycle event search page
parent
fb640e7b
Pipeline
#8901
failed with stage
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/bundle/lifeCycle/Controller/journal.php
View file @
c4c48dc1
...
...
@@ -313,8 +313,8 @@ class journal
* @param string $objectId The identifier of the object
* @param timestamp $minDate The minimum date of the event
* @param timestamp $maxDate The maximum date of the event
* @param sring
$sortBy The event sorting request
* @param int $
numberOf
Result The number of result
* @param s
t
ring $sortBy The event sorting request
* @param int $
max
Result
s
The number of result
*
* @throws \Exception
*
...
...
@@ -327,10 +327,64 @@ class journal
$minDate
=
null
,
$maxDate
=
null
,
$sortBy
=
">timestamp"
,
$
numberOf
Result
=
null
$
max
Result
s
=
null
)
{
$query
=
array
();
$queryParams
=
array
();
list
(
$queryParams
,
$queryString
)
=
$this
->
queryBuilder
(
$eventType
,
$objectClass
,
$objectId
,
$minDate
,
$maxDate
);
$events
=
$this
->
sdoFactory
->
find
(
'lifeCycle/event'
,
$queryString
,
$queryParams
,
$sortBy
,
null
,
$maxResults
);
$userAccountController
=
\
laabs
::
newController
(
'auth/userAccount'
);
$users
=
$userAccountController
->
index
();
foreach
(
$users
as
$i
=>
$user
)
{
$users
[(
string
)
$user
->
accountId
]
=
$user
;
unset
(
$users
[
$i
]);
}
$serviceAccountController
=
\
laabs
::
newController
(
'auth/serviceAccount'
);
$services
=
$serviceAccountController
->
index
();
foreach
(
$services
as
$i
=>
$service
)
{
$services
[(
string
)
$service
->
accountId
]
=
$service
;
unset
(
$services
[
$i
]);
}
foreach
(
$events
as
$i
=>
$event
)
{
if
(
isset
(
$event
->
accountId
)
&&
isset
(
$users
[(
string
)
$event
->
accountId
]))
{
$event
->
accountName
=
$users
[(
string
)
$event
->
accountId
]
->
accountName
;
}
elseif
(
isset
(
$event
->
accountId
)
&&
isset
(
$services
[(
string
)
$event
->
accountId
]))
{
$event
->
accountName
=
$services
[(
string
)
$event
->
accountId
]
->
accountName
;
}
else
{
$event
->
accountName
=
"__system__"
;
}
}
return
$events
;
}
/**
* Build a search sql query
*
* @param string $eventType The type of the event
* @param string $objectClass The object class
* @param string $objectId The identifier of the object
* @param timestamp $minDate The minimum date of the event
* @param timestamp $maxDate The maximum date of the event
*/
protected
function
queryBuilder
(
$eventType
=
null
,
$objectClass
=
null
,
$objectId
=
null
,
$minDate
=
null
,
$maxDate
=
null
)
{
$query
=
[];
$queryParams
=
[];
if
(
$this
->
separateInstance
)
{
$queryParams
[
'instanceName'
]
=
\
laabs
::
getInstanceName
();
...
...
@@ -364,46 +418,42 @@ class journal
$queryString
=
implode
(
' AND '
,
$query
);
if
(
!
$numberOfResult
)
{
$numberOfResult
=
\
laabs
::
configuration
(
'presentation.maarchRM'
)[
'maxResults'
];
}
return
[
$queryParams
,
$queryString
];
}
$events
=
$this
->
sdoFactory
->
find
(
/**
* Count journal events
*
* @param string $eventType The type of the event
* @param string $objectClass The object class
* @param string $objectId The identifier of the object
* @param timestamp $minDate The minimum date of the event
* @param timestamp $maxDate The maximum date of the event
* @param string $sortBy The event sorting request
*
* @throws \Exception
*
* @return integer Count results of request
*/
public
function
searchCount
(
$eventType
=
null
,
$objectClass
=
null
,
$objectId
=
null
,
$minDate
=
null
,
$maxDate
=
null
,
$sortBy
=
">timestamp"
)
{
list
(
$queryParams
,
$queryString
)
=
$this
->
queryBuilder
(
$eventType
,
$objectClass
,
$objectId
,
$minDate
,
$maxDate
);
$count
=
$this
->
sdoFactory
->
count
(
'lifeCycle/event'
,
$queryString
,
$queryParams
,
$sortBy
,
null
,
$numberOfResult
$sortBy
);
$userAccountController
=
\
laabs
::
newController
(
'auth/userAccount'
);
$users
=
$userAccountController
->
index
();
foreach
(
$users
as
$i
=>
$user
)
{
$users
[(
string
)
$user
->
accountId
]
=
$user
;
unset
(
$users
[
$i
]);
}
$serviceAccountController
=
\
laabs
::
newController
(
'auth/serviceAccount'
);
$services
=
$serviceAccountController
->
index
();
foreach
(
$services
as
$i
=>
$service
)
{
$services
[(
string
)
$service
->
accountId
]
=
$service
;
unset
(
$services
[
$i
]);
}
foreach
(
$events
as
$i
=>
$event
)
{
if
(
isset
(
$event
->
accountId
)
&&
isset
(
$users
[(
string
)
$event
->
accountId
]))
{
$event
->
accountName
=
$users
[(
string
)
$event
->
accountId
]
->
accountName
;
}
elseif
(
isset
(
$event
->
accountId
)
&&
isset
(
$services
[(
string
)
$event
->
accountId
]))
{
$event
->
accountName
=
$services
[(
string
)
$event
->
accountId
]
->
accountName
;
}
else
{
$event
->
accountName
=
"__system__"
;
}
}
return
$events
;
return
$count
;
}
/**
* Load a journal
* @param string $journalReference The id of the journal or the journal object
...
...
src/bundle/lifeCycle/eventInterface.php
View file @
c4c48dc1
...
...
@@ -34,6 +34,8 @@ interface eventInterface
* @param string $objectId The identifier of the object
* @param timestamp $minDate The minimum date of the event
* @param timestamp $maxDate The maximum date of the event
* @param string $sortBy The event sorting request
* @param integer $maxResults Maximum number of results to search
*
* @action lifeCycle/journal/searchEvent
*/
...
...
@@ -42,7 +44,31 @@ interface eventInterface
$objectClass
=
false
,
$objectId
=
false
,
$minDate
=
false
,
$maxDate
=
false
$maxDate
=
false
,
$sortBy
=
">timestamp"
,
$maxResults
=
null
);
/**
* Search a journal event
* @param string $eventType The type of the event
* @param string $objectClass The class of the object
* @param string $objectId The identifier of the object
* @param timestamp $minDate The minimum date of the event
* @param timestamp $maxDate The maximum date of the event
* @param string $sortBy The event sorting request
* @param integer $maxResults Maximum number of results to search
*
* @action lifeCycle/journal/searchCount
*/
public
function
readCount
(
$eventType
=
false
,
$objectClass
=
false
,
$objectId
=
false
,
$minDate
=
false
,
$maxDate
=
false
,
$sortBy
=
">timestamp"
,
$maxResults
=
null
);
/**
...
...
src/presentation/maarchRM/Presenter/lifeCycle/journal.php
View file @
c4c48dc1
...
...
@@ -135,7 +135,13 @@ class journal
});
}
$maxResults
=
null
;
if
(
isset
(
\
laabs
::
configuration
(
'presentation.maarchRM'
)[
'maxResults'
]))
{
$maxResults
=
\
laabs
::
configuration
(
'presentation.maarchRM'
)[
'maxResults'
];
}
$this
->
view
->
setSource
(
"eventType"
,
$eventDomains
);
$this
->
view
->
setSource
(
"maxResults"
,
$maxResults
);
$this
->
view
->
merge
();
$this
->
view
->
translate
();
...
...
@@ -156,7 +162,7 @@ class journal
$this
->
view
->
setSource
(
'journals'
,
$journals
);
$this
->
view
->
merge
();
$dataTable
=
$this
->
view
->
getElementsByClass
(
"dataTable"
)
->
item
(
0
)
->
plugin
[
'dataTable'
];
$dataTable
->
setPaginationType
(
"full_numbers"
);
$dataTable
->
setUnsortableColumns
(
2
);
...
...
@@ -198,7 +204,7 @@ class journal
*
* @return string
*/
public
function
searchEvent
(
$events
)
public
function
searchEvent
(
$events
,
$totalResults
)
{
$this
->
view
->
addContentFile
(
"lifeCycle/searchResult.html"
);
...
...
@@ -221,6 +227,14 @@ class journal
}
}
$hasReachMaxResults
=
false
;
if
(
isset
(
\
laabs
::
configuration
(
'presentation.maarchRM'
)[
'maxResults'
])
&&
$totalResults
>=
\
laabs
::
configuration
(
'presentation.maarchRM'
)[
'maxResults'
])
{
$hasReachMaxResults
=
true
;
}
$this
->
view
->
setSource
(
'hasReachMaxResults'
,
$hasReachMaxResults
);
$this
->
view
->
setSource
(
'totalResults'
,
$totalResults
);
$this
->
view
->
setSource
(
'hasCertificatePrivilege'
,
$hasCertificatePrivilege
);
$this
->
view
->
setSource
(
'events'
,
$events
);
$this
->
view
->
merge
();
...
...
@@ -236,10 +250,10 @@ class journal
$dataTable
->
setUnsortableColumns
(
4
);
$dataTable
->
setSorting
(
array
(
array
(
1
,
'desc'
)));
}
return
$this
->
view
->
saveHtml
();
}
//JSON
/**
* Serializer JSON for create method
...
...
@@ -279,7 +293,7 @@ class journal
$eventObject
->
accountDisplayName
=
$user
->
displayName
.
' ('
.
$user
->
accountName
.
')'
;
$this
->
translator
->
setCatalog
(
'lifeCycle/messages'
);
$eventObject
->
description
=
$this
->
translator
->
getText
(
$event
->
description
);
$eventObject
->
objectClass
=
$this
->
translator
->
getText
(
$event
->
objectClass
);
$eventObject
->
eventType
=
$this
->
translator
->
getText
(
$event
->
eventType
);
...
...
@@ -289,11 +303,11 @@ class journal
return
$this
->
json
->
save
();
}
/**
* Exception
* @param lifeCycle/Exception/journalException $journalException
*
*
* @return string
*/
public
function
journalException
(
$journalException
)
...
...
src/presentation/maarchRM/Resources/view/lifeCycle/searchForm.html
View file @
c4c48dc1
...
...
@@ -22,6 +22,7 @@
</div>
<div
id=
"collapseOne"
class=
"well panel-collapse collapse in"
style=
"margin-bottom: 0px"
>
<form
class=
"form-horizontal"
>
<input
type=
"hidden"
id=
"maxResults"
value=
"[?merge maxResults ?]"
>
<div
class=
"row"
>
<div
class=
"col-md-6 col-lg-5 col-lg-offset-1"
>
<div
class=
"form-group"
>
...
...
@@ -78,8 +79,8 @@
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div
class=
"container-fluid"
id=
"searchResult"
>
</div>
...
...
@@ -89,7 +90,7 @@
<!-- Modal -->
<?hinclude lifeCycle/eventModal.html ?>
</div>
<script>
...
...
@@ -116,7 +117,7 @@
}
// Prevent form submit
e
.
preventDefault
();
$
(
"
#search
"
).
click
();
});
...
...
@@ -141,12 +142,14 @@
url
:
"
/journals
"
,
type
:
"
GET
"
,
data
:
{
eventType
:
eventType
,
objectClass
:
objectClass
,
objectId
:
objectId
,
minDate
:
minDate
,
maxDate
:
maxDate
},
eventType
:
eventType
,
objectClass
:
objectClass
,
objectId
:
objectId
,
minDate
:
minDate
,
maxDate
:
maxDate
,
sortBy
:
"
>timestamp
"
,
maxResults
:
parseInt
(
$
(
'
#maxResults
'
).
val
(),
10
)
},
contentType
:
'
application/json
'
,
dataType
:
'
html
'
,
success
:
function
(
response
){
...
...
src/presentation/maarchRM/Resources/view/lifeCycle/searchResult.html
View file @
c4c48dc1
...
...
@@ -3,7 +3,10 @@
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading clearfix"
>
<div
class=
"pull-left"
>
<?merge hasReachMaxResults.not() ?>
<h4>
<?merge events.count() ?>
result(s)
</h4>
<?merge hasReachMaxResults ?>
<h4>
<?merge events.count() ?>
result(s) on
<?merge totalResults ?>
total
</h4>
</div>
</div>
<div
class=
"panel-body"
style=
"padding: 0;"
>
...
...
src/presentation/maarchRM/UserStory/journal/lifeCycleJournalInterface.php
View file @
c4c48dc1
...
...
@@ -34,16 +34,20 @@ interface lifeCycleJournalInterface
/**
* Search a journal event
* @param string $eventType The type of the event
* @param string $objectClass The class of the object
* @param string $objectId The identifier of the object
* @param string $minDate The minimum date of the event
* @param string $maxDate The maximum date of the event
* @param string $eventType The type of the event
* @param string $objectClass The class of the object
* @param string $objectId The identifier of the object
* @param string $minDate The minimum date of the event
* @param string $maxDate The maximum date of the event
* @param string $sortBy The event sorting request
* @param integer $maxResults Maximum number of results to display
*
* @return lifeCycle/journal/searchEvent
* @uses lifeCycle/event/readSearch
* @uses lifeCycle/event/readCount
*
* @return lifeCycle/journal/searchEvent
*/
public
function
readJournals
(
$eventType
=
false
,
$objectClass
=
false
,
$objectId
=
false
,
$minDate
=
false
,
$maxDate
=
false
);
public
function
readJournals
(
$eventType
=
false
,
$objectClass
=
false
,
$objectId
=
false
,
$minDate
=
false
,
$maxDate
=
false
,
$sortBy
=
">timestamp"
,
$maxResults
=
null
);
/**
* Get the current journal
...
...
@@ -57,4 +61,4 @@ interface lifeCycleJournalInterface
*
*/
public
function
readJournal_journalId_
(
$journalId
,
$offset
=
0
,
$limit
=
300
);
}
\ No newline at end of file
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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