Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating code with search by resource type #27

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions client/src/app/+search/search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,32 @@
<input name="id" type="text" class="form-control" [(ngModel)]="filtro.id" placeholder="ID do Log">

<br><span>Data Início: </span><br>
<input name="dataInicio" type="datetime-local" class="input form-control primary-border" [(ngModel)]="dateStart"
placeholder="dd/mm/aaaa --:--">
<p-calendar name="dataInicio" dateFormat="dd.mm.yy" [(ngModel)]="dateStart" [maxDate]="dateEnd" [showTime]="true" [showIcon]="true"></p-calendar>


<br><span>Data Fim: </span><br>
<input name="dataFim" type="datetime-local" class="input form-control primary-border" [(ngModel)]="dateEnd"
placeholder="dd/mm/aaaa --:--">
<p-calendar name="dataFim" dateFormat="dd.mm.yy" [(ngModel)]="dateEnd" [minDate]="dateStart" [showTime]="true" [showIcon]="true"></p-calendar>

<br><span>Ip: </span><br>
<input name="ip" type="text" class="input form-control primary-border" [(ngModel)]="filtro.ip" placeholder="IP">

<br>Criticidade
<br><select name="securitySevel" class="form-control"
[(ngModel)]="filtro.securityLevel">

<br><br><select name="securitySevel" class="form-control"
[(ngModel)]="filtro.securityLevel">

<option value="" selected>---Criticidade---</option> <!-- not selected / blank option -->
<option value="">---Criticidade---</option> <!-- not selected / blank option -->
<option *ngFor="let crit of criticidades" value="{{crit}}"> {{crit}}</option>

</select>

<select name="applicationName" class="form-control"
[(ngModel)]="filtro.applicationName">
<br>Aplicação
<br><select name="applicationName" class="form-control"
[(ngModel)]="filtro.applicationName">

<option value="" selected>---Aplicação---</option> <!-- not selected / blank option -->
<option *ngFor="let aplic of aplicacoes" value="{{aplic}}"> {{aplic}}</option>
<option value="" selected>---Aplicação---</option> <!-- not selected / blank option -->
<option *ngFor="let aplic of aplicacoes" value="{{aplic}}" > {{aplic}}</option>

</select>
</select>

<br>Resource Types
<br><select name="resourceTypes" class="form-control"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public SearchResponse search(Map<String, Object> filtro, Long start, Long max,
}

public List<String> listApplicationNames() {
return em.createQuery("SELECT distinct e.applicationName from AuditEvent e").getResultList();
return em.createQuery("SELECT distinct e.applicationName from AuditEvent e order by e.applicationName").getResultList();
}

public List<String> listResourceTypes(){
return em.createQuery("SELECT distinct e.resource.resourceType from AuditEvent e").getResultList();
return em.createQuery("SELECT distinct e.resource.resourceType from AuditEvent e order by e.resource.resourceType").getResultList();
}

private SearchResponse buildQuery(Map<String, Object> filtro,
Expand All @@ -68,11 +68,14 @@ private SearchResponse buildQuery(Map<String, Object> filtro,

List<Predicate> predicates = new ArrayList();


Iterator it = filtro.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next();
String key = (String) pair.getKey();
if (key == "action") {
if(key.equals("resourceType")){
predicates.add(cb.equal(root.get("resource").get(key), pair.getValue()));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is better to be a like not equal. User should be able to search for a teach and return teacher or teachers

}else if (key.equals("action")) {
predicates.add(cb.like(root.get(key), pair.getValue() + "%"));
} else {
predicates.add(cb.equal(root.get(key), pair.getValue()));
Expand Down