1 package comum.database;
2
3 import gov.pr.celepar.sentinela.comunicacao.SentinelaAdmInterface;
4 import gov.pr.celepar.sentinela.comunicacao.SentinelaAdministracao;
5 import gov.pr.celepar.sentinela.comunicacao.SentinelaComunicacao;
6 import gov.pr.celepar.sentinela.comunicacao.SentinelaInterface;
7 import gov.pr.celepar.sentinela.comunicacao.SentinelaParam;
8
9 import javax.servlet.http.HttpServletRequest;
10
11
12
13
14
15
16 public class SentinelaUtil {
17 private static final ThreadLocal<SentinelaInterface> thread = new ThreadLocal<SentinelaInterface>();
18 private SentinelaInterface sentinelaInterface = null;
19
20
21
22
23
24
25
26
27
28
29 public SentinelaUtil(HttpServletRequest request) {
30 sentinelaInterface = SentinelaComunicacao.getInstance(request);
31 thread.set(sentinelaInterface);
32 }
33
34
35
36
37
38
39
40
41
42 public static SentinelaInterface getSentinelaInterface() {
43 return (SentinelaInterface)thread.get();
44 }
45
46
47
48
49
50
51
52
53
54
55 public static SentinelaAdmInterface getSentinelaAdmInterface(HttpServletRequest request) {
56 return SentinelaAdministracao.getInstance (request);
57 }
58
59
60
61
62
63
64
65 public static SentinelaParam[] getGruposNaoVinculados(SentinelaParam[] grupos, SentinelaParam[] vinculados ){
66
67
68 SentinelaParam[] naoVinculados = new SentinelaParam[grupos.length - vinculados.length ] ;
69
70 int contNaoVinculado = 0;
71 for (int i =0; i<grupos.length;i++){
72 boolean ehVinculado = false;
73
74 for (int j = 0; j<vinculados.length;j++ ){
75 if ( grupos[i].getCodigo()== vinculados[j].getCodigo() ){
76 ehVinculado = true;
77 break;
78 }
79 }
80
81 if (! ehVinculado){
82 naoVinculados[contNaoVinculado++]=grupos[i] ;
83 }
84
85 }
86
87 return naoVinculados;
88
89 }
90
91 }