1
+ /*
2
+ * Copyright 2018 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
package org.utplsql.sqldev
2
17
3
18
import java.awt.Desktop
@@ -7,6 +22,7 @@ import java.nio.charset.StandardCharsets
7
22
import java.nio.file.Files
8
23
import java.nio.file.Paths
9
24
import java.sql.Connection
25
+ import java.util.ArrayList
10
26
import java.util.List
11
27
import java.util.logging.Logger
12
28
import oracle.dbtools.raptor.utils.Connections
@@ -17,12 +33,24 @@ class CodeCoverageReporter {
17
33
18
34
var Connection conn
19
35
var List<String > pathList
36
+ var List<String > includeObjectList
37
+ var CodeCoverageReporterWindow frame
38
+ var String schemas
39
+ var String includeObjects
40
+ var String excludeObjects
20
41
21
- new (List<String > pathList, String connectionName) {
42
+ new (List<String > pathList, List< String > includeObjectList, String connectionName) {
22
43
this . pathList = pathList
44
+ this . includeObjectList = includeObjectList
23
45
setConnection(connectionName)
24
46
}
25
47
48
+ new (List<String > pathList, List<String > includeObjectList, Connection conn) {
49
+ this . pathList = pathList
50
+ this . includeObjectList = includeObjectList
51
+ this . conn = conn
52
+ }
53
+
26
54
private def setConnection (String connectionName ) {
27
55
if (connectionName == = null ) {
28
56
throw new RuntimeException (" Cannot initialize a CodeCoverageReporter without a ConnectionName" )
@@ -31,12 +59,24 @@ class CodeCoverageReporter {
31
59
this . conn = Connections . instance. cloneConnection(Connections . instance. getConnection(connectionName))
32
60
}
33
61
}
62
+
63
+ private def toStringList (String s ) {
64
+ val list = new ArrayList<String >
65
+ if (s !== null && ! s. empty) {
66
+ for (item : s. split(" ," )) {
67
+ if (! item. empty) {
68
+ list. add(item. trim)
69
+ }
70
+ }
71
+ }
72
+ return list
73
+ }
34
74
35
- private def run () {
75
+ private def void run () {
36
76
try {
37
77
logger. fine(' ' ' Running code coverage reporter for «pathList»...' ' ' )
38
78
val dal = new UtplsqlDao (conn)
39
- val content = dal. htmlCodeCoverage(pathList)
79
+ val content = dal. htmlCodeCoverage(pathList, toStringList(schemas), toStringList(includeObjects), toStringList(excludeObjects) )
40
80
val file = File . createTempFile(" utplsql_" , " html" )
41
81
logger. fine(' ' ' Writing result to «file.absolutePath»...' ' ' )
42
82
Files . write(Paths . get(file. absolutePath), content. split(System . lineSeparator), StandardCharsets . UTF_8 );
@@ -54,8 +94,47 @@ class CodeCoverageReporter {
54
94
}
55
95
finally {
56
96
conn. close
97
+ if (frame !== null ) {
98
+ frame. exit
99
+ }
57
100
}
58
101
}
102
+
103
+ def setFrame (CodeCoverageReporterWindow frame ) {
104
+ this . frame = frame;
105
+ }
106
+
107
+ def getFrame () {
108
+ return this . frame
109
+ }
110
+
111
+ def getConnection () {
112
+ return conn
113
+ }
114
+
115
+ def getPathList () {
116
+ return pathList
117
+ }
118
+
119
+ def getIncludeObjectList () {
120
+ if (includeObjectList == = null ) {
121
+ return new ArrayList<String >
122
+ } else {
123
+ return includeObjectList
124
+ }
125
+ }
126
+
127
+ def setSchemas (String schemas ) {
128
+ this . schemas = schemas
129
+ }
130
+
131
+ def setIncludeObjects (String includeObjects ) {
132
+ this . includeObjects = includeObjects
133
+ }
134
+
135
+ def setExcludeObjects (String excludeObjects ) {
136
+ this . excludeObjects = excludeObjects
137
+ }
59
138
60
139
def runAsync () {
61
140
val Runnable runnable = [|run]
@@ -64,4 +143,8 @@ class CodeCoverageReporter {
64
143
thread. start
65
144
}
66
145
146
+ def showParameterWindow () {
147
+ CodeCoverageReporterWindow . createAndShow(this )
148
+ }
149
+
67
150
}
0 commit comments