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+ */
116package org.utplsql.sqldev
217
318import java.awt.Desktop
@@ -7,6 +22,7 @@ import java.nio.charset.StandardCharsets
722import java.nio.file.Files
823import java.nio.file.Paths
924import java.sql.Connection
25+ import java.util.ArrayList
1026import java.util.List
1127import java.util.logging.Logger
1228import oracle.dbtools.raptor.utils.Connections
@@ -17,12 +33,24 @@ class CodeCoverageReporter {
1733
1834 var Connection conn
1935 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
2041
21- new (List<String > pathList, String connectionName) {
42+ new (List<String > pathList, List< String > includeObjectList, String connectionName) {
2243 this . pathList = pathList
44+ this . includeObjectList = includeObjectList
2345 setConnection(connectionName)
2446 }
2547
48+ new (List<String > pathList, List<String > includeObjectList, Connection conn) {
49+ this . pathList = pathList
50+ this . includeObjectList = includeObjectList
51+ this . conn = conn
52+ }
53+
2654 private def setConnection (String connectionName ) {
2755 if (connectionName == = null ) {
2856 throw new RuntimeException (" Cannot initialize a CodeCoverageReporter without a ConnectionName" )
@@ -31,12 +59,24 @@ class CodeCoverageReporter {
3159 this . conn = Connections . instance. cloneConnection(Connections . instance. getConnection(connectionName))
3260 }
3361 }
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+ }
3474
35- private def run () {
75+ private def void run () {
3676 try {
3777 logger. fine(' ' ' Running code coverage reporter for «pathList»...' ' ' )
3878 val dal = new UtplsqlDao (conn)
39- val content = dal. htmlCodeCoverage(pathList)
79+ val content = dal. htmlCodeCoverage(pathList, toStringList(schemas), toStringList(includeObjects), toStringList(excludeObjects) )
4080 val file = File . createTempFile(" utplsql_" , " html" )
4181 logger. fine(' ' ' Writing result to «file.absolutePath»...' ' ' )
4282 Files . write(Paths . get(file. absolutePath), content. split(System . lineSeparator), StandardCharsets . UTF_8 );
@@ -54,8 +94,47 @@ class CodeCoverageReporter {
5494 }
5595 finally {
5696 conn. close
97+ if (frame !== null ) {
98+ frame. exit
99+ }
57100 }
58101 }
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+ }
59138
60139 def runAsync () {
61140 val Runnable runnable = [|run]
@@ -64,4 +143,8 @@ class CodeCoverageReporter {
64143 thread. start
65144 }
66145
146+ def showParameterWindow () {
147+ CodeCoverageReporterWindow . createAndShow(this )
148+ }
149+
67150}
0 commit comments