2655 |
22 Sep 06 |
nicklas |
1 |
<%-- $Id$ |
2655 |
22 Sep 06 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006 Johan Enell, Nicklas Nordborg |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg |
2655 |
22 Sep 06 |
nicklas |
5 |
|
2655 |
22 Sep 06 |
nicklas |
6 |
This file is part of BASE - BioArray Software Environment. |
2655 |
22 Sep 06 |
nicklas |
7 |
Available at http://base.thep.lu.se/ |
2655 |
22 Sep 06 |
nicklas |
8 |
|
2655 |
22 Sep 06 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
2655 |
22 Sep 06 |
nicklas |
10 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
11 |
as published by the Free Software Foundation; either version 3 |
2655 |
22 Sep 06 |
nicklas |
12 |
of the License, or (at your option) any later version. |
2655 |
22 Sep 06 |
nicklas |
13 |
|
2655 |
22 Sep 06 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
2655 |
22 Sep 06 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2655 |
22 Sep 06 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2655 |
22 Sep 06 |
nicklas |
17 |
GNU General Public License for more details. |
2655 |
22 Sep 06 |
nicklas |
18 |
|
2655 |
22 Sep 06 |
nicklas |
19 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
20 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2655 |
22 Sep 06 |
nicklas |
21 |
------------------------------------------------------------------ |
2655 |
22 Sep 06 |
nicklas |
22 |
|
2655 |
22 Sep 06 |
nicklas |
23 |
@author Nicklas |
2655 |
22 Sep 06 |
nicklas |
24 |
@version 2.0 |
2655 |
22 Sep 06 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
2992 |
01 Dec 06 |
enell |
27 |
contentType="text/html; charset=UTF-8" |
2655 |
22 Sep 06 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
2655 |
22 Sep 06 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
2992 |
01 Dec 06 |
enell |
30 |
import="net.sf.basedb.core.Config" |
2655 |
22 Sep 06 |
nicklas |
31 |
import="net.sf.basedb.core.Item" |
2655 |
22 Sep 06 |
nicklas |
32 |
import="net.sf.basedb.core.File" |
2655 |
22 Sep 06 |
nicklas |
33 |
import="net.sf.basedb.core.Path" |
2655 |
22 Sep 06 |
nicklas |
34 |
import="net.sf.basedb.core.Location" |
8144 |
21 Apr 23 |
nicklas |
35 |
import="net.sf.basedb.core.StringUtil" |
4105 |
28 Jan 08 |
nicklas |
36 |
import="net.sf.basedb.core.PluginConfigurationRequest" |
4105 |
28 Jan 08 |
nicklas |
37 |
import="net.sf.basedb.core.plugin.Plugin" |
2655 |
22 Sep 06 |
nicklas |
38 |
import="net.sf.basedb.util.parser.FlatFileParser" |
4105 |
28 Jan 08 |
nicklas |
39 |
import="net.sf.basedb.util.parser.WrappedConfigureByExample" |
2655 |
22 Sep 06 |
nicklas |
40 |
import="net.sf.basedb.clients.web.Base" |
2753 |
20 Oct 06 |
nicklas |
41 |
import="net.sf.basedb.util.Values" |
7654 |
15 Mar 19 |
nicklas |
42 |
import="net.sf.basedb.util.formatter.DateFormatter" |
7654 |
15 Mar 19 |
nicklas |
43 |
import="net.sf.basedb.util.NumberFormatUtil" |
7654 |
15 Mar 19 |
nicklas |
44 |
import="net.sf.basedb.util.excel.XlsxToCsvUtil" |
7654 |
15 Mar 19 |
nicklas |
45 |
import="net.sf.basedb.util.excel.XlsxToCsvUtil.SheetInfo" |
4419 |
27 Aug 08 |
nicklas |
46 |
import="net.sf.basedb.util.fuzzy.StringMatcher" |
4419 |
27 Aug 08 |
nicklas |
47 |
import="net.sf.basedb.util.fuzzy.StringMatcher.FuzzyMatch" |
2655 |
22 Sep 06 |
nicklas |
48 |
import="net.sf.basedb.clients.web.util.HTML" |
2655 |
22 Sep 06 |
nicklas |
49 |
import="java.util.regex.Pattern" |
2655 |
22 Sep 06 |
nicklas |
50 |
import="java.util.List" |
2655 |
22 Sep 06 |
nicklas |
51 |
import="java.util.ArrayList" |
2655 |
22 Sep 06 |
nicklas |
52 |
import="java.util.Set" |
2655 |
22 Sep 06 |
nicklas |
53 |
import="java.io.InputStream" |
6200 |
05 Nov 12 |
nicklas |
54 |
import="org.json.simple.JSONArray" |
7494 |
04 Jun 18 |
nicklas |
55 |
import="org.json.simple.JSONObject" |
2655 |
22 Sep 06 |
nicklas |
56 |
%> |
2655 |
22 Sep 06 |
nicklas |
57 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2655 |
22 Sep 06 |
nicklas |
58 |
<%@ taglib prefix="m" uri="/WEB-INF/menu.tld" %> |
2655 |
22 Sep 06 |
nicklas |
59 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
5955 |
13 Feb 12 |
nicklas |
60 |
<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
2655 |
22 Sep 06 |
nicklas |
61 |
|
2655 |
22 Sep 06 |
nicklas |
62 |
<% |
2992 |
01 Dec 06 |
enell |
63 |
request.setCharacterEncoding("UTF-8"); |
2655 |
22 Sep 06 |
nicklas |
64 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2655 |
22 Sep 06 |
nicklas |
65 |
final String ID = sc.getId(); |
7954 |
12 May 21 |
nicklas |
66 |
final DbControl dc = sc.newDbControl(":Test with file - Parse file"); |
2655 |
22 Sep 06 |
nicklas |
67 |
final float scale = Base.getScale(sc); |
2655 |
22 Sep 06 |
nicklas |
68 |
InputStream fileInputStream = null; |
2655 |
22 Sep 06 |
nicklas |
69 |
try |
2655 |
22 Sep 06 |
nicklas |
70 |
{ |
2655 |
22 Sep 06 |
nicklas |
71 |
String path = request.getParameter("path"); |
7654 |
15 Mar 19 |
nicklas |
72 |
boolean excelMode = "excel".equals(Values.getString(request.getParameter("filemode"))); |
7654 |
15 Mar 19 |
nicklas |
73 |
String charsetName = Values.getString(request.getParameter("charset"), excelMode ? "UTF-8" : Config.getCharset()); |
7654 |
15 Mar 19 |
nicklas |
74 |
String sheet = Values.getStringOrNull(request.getParameter("sheet")); |
7605 |
26 Feb 19 |
nicklas |
75 |
PluginConfigurationRequest pcRequest = sc.getSessionSetting("plugin.configure.request"); |
4105 |
28 Jan 08 |
nicklas |
76 |
Plugin plugin = pcRequest.getPlugin(); |
4105 |
28 Jan 08 |
nicklas |
77 |
|
2655 |
22 Sep 06 |
nicklas |
78 |
File file = null; |
2655 |
22 Sep 06 |
nicklas |
79 |
FlatFileParser parser = null; |
2655 |
22 Sep 06 |
nicklas |
80 |
FlatFileParser.LineType lastLine = null; |
8144 |
21 Apr 23 |
nicklas |
81 |
FlatFileParser.Data firstDataLine = null; |
2655 |
22 Sep 06 |
nicklas |
82 |
Pattern splitter = null; |
2655 |
22 Sep 06 |
nicklas |
83 |
boolean dataIsFound = false; |
2655 |
22 Sep 06 |
nicklas |
84 |
int maxLines = Values.getInt(request.getParameter("maxLines"), FlatFileParser.DEFAULT_MAX_UNKNOWN_LINES); |
2655 |
22 Sep 06 |
nicklas |
85 |
|
2655 |
22 Sep 06 |
nicklas |
86 |
List<String> messages = new ArrayList<String>(); |
6200 |
05 Nov 12 |
nicklas |
87 |
JSONArray linePatterns = new JSONArray(); |
6200 |
05 Nov 12 |
nicklas |
88 |
JSONArray jsonFuzzy = new JSONArray(); |
2655 |
22 Sep 06 |
nicklas |
89 |
|
2655 |
22 Sep 06 |
nicklas |
90 |
if (path != null) |
2655 |
22 Sep 06 |
nicklas |
91 |
{ |
2655 |
22 Sep 06 |
nicklas |
92 |
Path p = new Path(path, Path.Type.FILE); |
2655 |
22 Sep 06 |
nicklas |
93 |
file = File.getByPath(dc, p, false); |
2655 |
22 Sep 06 |
nicklas |
94 |
parser = new FlatFileParser(); |
2655 |
22 Sep 06 |
nicklas |
95 |
parser.setMaxUnknownLines(maxLines); |
2655 |
22 Sep 06 |
nicklas |
96 |
|
2655 |
22 Sep 06 |
nicklas |
97 |
String header = Values.getStringOrNull(request.getParameter("header")); |
2655 |
22 Sep 06 |
nicklas |
98 |
if (header != null) |
2655 |
22 Sep 06 |
nicklas |
99 |
{ |
2655 |
22 Sep 06 |
nicklas |
100 |
try |
2655 |
22 Sep 06 |
nicklas |
101 |
{ |
2655 |
22 Sep 06 |
nicklas |
102 |
parser.setHeaderRegexp(Pattern.compile(header)); |
2655 |
22 Sep 06 |
nicklas |
103 |
} |
2655 |
22 Sep 06 |
nicklas |
104 |
catch (Throwable t) |
2655 |
22 Sep 06 |
nicklas |
105 |
{ |
2655 |
22 Sep 06 |
nicklas |
106 |
messages.add("Invalid regular expression for header: " + HTML.encodeTags(header)); |
2655 |
22 Sep 06 |
nicklas |
107 |
} |
2655 |
22 Sep 06 |
nicklas |
108 |
} |
2655 |
22 Sep 06 |
nicklas |
109 |
|
7654 |
15 Mar 19 |
nicklas |
110 |
String dataSplitter = Values.getString(request.getParameter("dataSplitter"), excelMode ? "\\t" : null); |
2655 |
22 Sep 06 |
nicklas |
111 |
if (dataSplitter != null) |
2655 |
22 Sep 06 |
nicklas |
112 |
{ |
2655 |
22 Sep 06 |
nicklas |
113 |
try |
2655 |
22 Sep 06 |
nicklas |
114 |
{ |
2655 |
22 Sep 06 |
nicklas |
115 |
splitter = Pattern.compile(dataSplitter); |
2655 |
22 Sep 06 |
nicklas |
116 |
parser.setDataSplitterRegexp(splitter); |
2655 |
22 Sep 06 |
nicklas |
117 |
} |
2655 |
22 Sep 06 |
nicklas |
118 |
catch (Throwable t) |
2655 |
22 Sep 06 |
nicklas |
119 |
{ |
2655 |
22 Sep 06 |
nicklas |
120 |
messages.add("Invalid regular expression for data splitter: " + HTML.encodeTags(dataSplitter)); |
2655 |
22 Sep 06 |
nicklas |
121 |
} |
2655 |
22 Sep 06 |
nicklas |
122 |
} |
2655 |
22 Sep 06 |
nicklas |
123 |
|
2655 |
22 Sep 06 |
nicklas |
124 |
String dataHeader = Values.getStringOrNull(request.getParameter("dataHeader")); |
2655 |
22 Sep 06 |
nicklas |
125 |
if (dataHeader != null) |
2655 |
22 Sep 06 |
nicklas |
126 |
{ |
2655 |
22 Sep 06 |
nicklas |
127 |
try |
2655 |
22 Sep 06 |
nicklas |
128 |
{ |
2655 |
22 Sep 06 |
nicklas |
129 |
parser.setDataHeaderRegexp(Pattern.compile(dataHeader)); |
2655 |
22 Sep 06 |
nicklas |
130 |
} |
2655 |
22 Sep 06 |
nicklas |
131 |
catch (Throwable t) |
2655 |
22 Sep 06 |
nicklas |
132 |
{ |
2655 |
22 Sep 06 |
nicklas |
133 |
messages.add("Invalid regular expression for data header: " + HTML.encodeTags(dataHeader)); |
2655 |
22 Sep 06 |
nicklas |
134 |
} |
2655 |
22 Sep 06 |
nicklas |
135 |
} |
2655 |
22 Sep 06 |
nicklas |
136 |
|
2655 |
22 Sep 06 |
nicklas |
137 |
String dataFooter = Values.getStringOrNull(request.getParameter("dataFooter")); |
2655 |
22 Sep 06 |
nicklas |
138 |
if (dataFooter != null) |
2655 |
22 Sep 06 |
nicklas |
139 |
{ |
2655 |
22 Sep 06 |
nicklas |
140 |
try |
2655 |
22 Sep 06 |
nicklas |
141 |
{ |
2655 |
22 Sep 06 |
nicklas |
142 |
parser.setDataFooterRegexp(Pattern.compile(dataFooter)); |
2655 |
22 Sep 06 |
nicklas |
143 |
} |
2655 |
22 Sep 06 |
nicklas |
144 |
catch (Throwable t) |
2655 |
22 Sep 06 |
nicklas |
145 |
{ |
2655 |
22 Sep 06 |
nicklas |
146 |
messages.add("Invalid regular expression for data footer: " + HTML.encodeTags(dataFooter)); |
2655 |
22 Sep 06 |
nicklas |
147 |
} |
2655 |
22 Sep 06 |
nicklas |
148 |
} |
2655 |
22 Sep 06 |
nicklas |
149 |
|
2655 |
22 Sep 06 |
nicklas |
150 |
String ignore = Values.getStringOrNull(request.getParameter("ignore")); |
2655 |
22 Sep 06 |
nicklas |
151 |
if (ignore != null) |
2655 |
22 Sep 06 |
nicklas |
152 |
{ |
2655 |
22 Sep 06 |
nicklas |
153 |
try |
2655 |
22 Sep 06 |
nicklas |
154 |
{ |
2655 |
22 Sep 06 |
nicklas |
155 |
parser.setIgnoreRegexp(Pattern.compile(ignore)); |
2655 |
22 Sep 06 |
nicklas |
156 |
} |
2655 |
22 Sep 06 |
nicklas |
157 |
catch (Throwable t) |
2655 |
22 Sep 06 |
nicklas |
158 |
{ |
2655 |
22 Sep 06 |
nicklas |
159 |
messages.add("Invalid regular expression for ignore: " + HTML.encodeTags(ignore)); |
2655 |
22 Sep 06 |
nicklas |
160 |
} |
2655 |
22 Sep 06 |
nicklas |
161 |
} |
2655 |
22 Sep 06 |
nicklas |
162 |
|
2655 |
22 Sep 06 |
nicklas |
163 |
parser.setTrimQuotes(Values.getBoolean(request.getParameter("trimQuotes"))); |
2655 |
22 Sep 06 |
nicklas |
164 |
parser.setMinDataColumns(Values.getInt(request.getParameter("minDataColumns"), 0)); |
2655 |
22 Sep 06 |
nicklas |
165 |
parser.setMaxDataColumns(Values.getInt(request.getParameter("maxDataColumns"), -1)); |
2655 |
22 Sep 06 |
nicklas |
166 |
|
2655 |
22 Sep 06 |
nicklas |
167 |
fileInputStream = file.getDownloadStream(0); |
4105 |
28 Jan 08 |
nicklas |
168 |
if (plugin instanceof WrappedConfigureByExample) |
4105 |
28 Jan 08 |
nicklas |
169 |
{ |
4105 |
28 Jan 08 |
nicklas |
170 |
WrappedConfigureByExample wex = (WrappedConfigureByExample)plugin; |
4105 |
28 Jan 08 |
nicklas |
171 |
fileInputStream = wex.wrapInputStream(fileInputStream); |
4105 |
28 Jan 08 |
nicklas |
172 |
} |
7655 |
19 Mar 19 |
nicklas |
173 |
|
7655 |
19 Mar 19 |
nicklas |
174 |
String dateFormat = Values.getStringOrNull(request.getParameter("dateFormat")); |
7655 |
19 Mar 19 |
nicklas |
175 |
if (dateFormat != null) parser.setDefaultDateFormat(new DateFormatter(dateFormat)); |
7655 |
19 Mar 19 |
nicklas |
176 |
String timestampFormat = Values.getStringOrNull(request.getParameter("timestampFormat")); |
7655 |
19 Mar 19 |
nicklas |
177 |
if (timestampFormat != null) parser.setDefaultTimestampFormat(new DateFormatter(timestampFormat)); |
7655 |
19 Mar 19 |
nicklas |
178 |
String decimalSeparator = Values.getStringOrNull(request.getParameter("decimalSeparator")); |
7655 |
19 Mar 19 |
nicklas |
179 |
if (decimalSeparator != null) |
7654 |
15 Mar 19 |
nicklas |
180 |
{ |
7655 |
19 Mar 19 |
nicklas |
181 |
char ds = "dot".equals(decimalSeparator) ? '.' : ','; |
7655 |
19 Mar 19 |
nicklas |
182 |
parser.setDefaultNumberFormat(NumberFormatUtil.getNumberFormat(ds, (char)0)); |
7654 |
15 Mar 19 |
nicklas |
183 |
} |
7656 |
19 Mar 19 |
nicklas |
184 |
parser.setExcelSheet(sheet); |
7656 |
19 Mar 19 |
nicklas |
185 |
parser.setInputStream(fileInputStream, charsetName); |
2655 |
22 Sep 06 |
nicklas |
186 |
lastLine = parser.parseHeaders(); |
2655 |
22 Sep 06 |
nicklas |
187 |
dataIsFound = lastLine == FlatFileParser.LineType.DATA || lastLine == FlatFileParser.LineType.DATA_HEADER; |
2655 |
22 Sep 06 |
nicklas |
188 |
if (!dataIsFound) |
2655 |
22 Sep 06 |
nicklas |
189 |
{ |
2655 |
22 Sep 06 |
nicklas |
190 |
messages.add("Start of data couldn't be found. Please try again with different settings."); |
2655 |
22 Sep 06 |
nicklas |
191 |
} |
2655 |
22 Sep 06 |
nicklas |
192 |
} |
2655 |
22 Sep 06 |
nicklas |
193 |
%> |
5955 |
13 Feb 12 |
nicklas |
194 |
<base:page type="iframe" title="Test with file"> |
7494 |
04 Jun 18 |
nicklas |
195 |
<base:head scripts="tabcontrol-2.js,~parse_file.js" styles="table.css,tabcontrol.css"> |
7494 |
04 Jun 18 |
nicklas |
196 |
<style> |
7494 |
04 Jun 18 |
nicklas |
197 |
#fileData td |
7494 |
04 Jun 18 |
nicklas |
198 |
{ |
7494 |
04 Jun 18 |
nicklas |
199 |
white-space: nowrap; |
7494 |
04 Jun 18 |
nicklas |
200 |
max-width: 20em; |
7494 |
04 Jun 18 |
nicklas |
201 |
min-width: 4em; |
7494 |
04 Jun 18 |
nicklas |
202 |
overflow: hidden; |
7494 |
04 Jun 18 |
nicklas |
203 |
text-overflow: ellipsis; |
7494 |
04 Jun 18 |
nicklas |
204 |
} |
7661 |
20 Mar 19 |
nicklas |
205 |
#fileData .line-no |
7494 |
04 Jun 18 |
nicklas |
206 |
{ |
7494 |
04 Jun 18 |
nicklas |
207 |
font-weight: bold; |
7661 |
20 Mar 19 |
nicklas |
208 |
text-align: right; |
7661 |
20 Mar 19 |
nicklas |
209 |
padding-right: 0.5em; |
7494 |
04 Jun 18 |
nicklas |
210 |
} |
7661 |
20 Mar 19 |
nicklas |
211 |
#fileData .num-cols, #fileData .line-type |
7494 |
04 Jun 18 |
nicklas |
212 |
{ |
7661 |
20 Mar 19 |
nicklas |
213 |
text-align: center; |
7661 |
20 Mar 19 |
nicklas |
214 |
} |
7661 |
20 Mar 19 |
nicklas |
215 |
#fileData tr.type-DATA_HEADER |
7661 |
20 Mar 19 |
nicklas |
216 |
{ |
7661 |
20 Mar 19 |
nicklas |
217 |
font-weight: bold; |
7661 |
20 Mar 19 |
nicklas |
218 |
border-top-style: solid; |
7661 |
20 Mar 19 |
nicklas |
219 |
border-bottom-style: solid; |
7661 |
20 Mar 19 |
nicklas |
220 |
border-top-color: #000000; |
7661 |
20 Mar 19 |
nicklas |
221 |
border-bottom-color: #000000; |
7661 |
20 Mar 19 |
nicklas |
222 |
} |
7661 |
20 Mar 19 |
nicklas |
223 |
#fileData tr.type-IGNORED |
7661 |
20 Mar 19 |
nicklas |
224 |
{ |
7661 |
20 Mar 19 |
nicklas |
225 |
font-style: italic; |
7494 |
04 Jun 18 |
nicklas |
226 |
color: #777777; |
7494 |
04 Jun 18 |
nicklas |
227 |
} |
7661 |
20 Mar 19 |
nicklas |
228 |
#fileData tr.type-HEADER td.col-0 |
7661 |
20 Mar 19 |
nicklas |
229 |
{ |
7661 |
20 Mar 19 |
nicklas |
230 |
color: #008800; |
7661 |
20 Mar 19 |
nicklas |
231 |
} |
7661 |
20 Mar 19 |
nicklas |
232 |
#fileData tr.type-HEADER td.col-1 |
7661 |
20 Mar 19 |
nicklas |
233 |
{ |
7661 |
20 Mar 19 |
nicklas |
234 |
color: #0000D0; |
7661 |
20 Mar 19 |
nicklas |
235 |
} |
8144 |
21 Apr 23 |
nicklas |
236 |
|
8144 |
21 Apr 23 |
nicklas |
237 |
#predefinedColumnMappings |
8144 |
21 Apr 23 |
nicklas |
238 |
{ |
8144 |
21 Apr 23 |
nicklas |
239 |
overflow-x: hidden; |
8144 |
21 Apr 23 |
nicklas |
240 |
overflow-y: auto; |
8144 |
21 Apr 23 |
nicklas |
241 |
} |
8144 |
21 Apr 23 |
nicklas |
242 |
|
8144 |
21 Apr 23 |
nicklas |
243 |
.file-column |
8144 |
21 Apr 23 |
nicklas |
244 |
{ |
8144 |
21 Apr 23 |
nicklas |
245 |
display: grid; |
8144 |
21 Apr 23 |
nicklas |
246 |
grid-template-columns: 1fr 1fr; |
8144 |
21 Apr 23 |
nicklas |
247 |
width: 32em; |
8144 |
21 Apr 23 |
nicklas |
248 |
padding: 0 !important; |
8144 |
21 Apr 23 |
nicklas |
249 |
} |
8144 |
21 Apr 23 |
nicklas |
250 |
|
8144 |
21 Apr 23 |
nicklas |
251 |
.file-column > div |
8144 |
21 Apr 23 |
nicklas |
252 |
{ |
8144 |
21 Apr 23 |
nicklas |
253 |
overflow: hidden; |
8144 |
21 Apr 23 |
nicklas |
254 |
padding: 3px 4px; |
8144 |
21 Apr 23 |
nicklas |
255 |
} |
8144 |
21 Apr 23 |
nicklas |
256 |
|
8144 |
21 Apr 23 |
nicklas |
257 |
.file-column > div.example |
8144 |
21 Apr 23 |
nicklas |
258 |
{ |
8144 |
21 Apr 23 |
nicklas |
259 |
background-color: #F8F8F8; |
8144 |
21 Apr 23 |
nicklas |
260 |
border-left-width: 1px; |
8144 |
21 Apr 23 |
nicklas |
261 |
border-left-style: dotted; |
8144 |
21 Apr 23 |
nicklas |
262 |
font-style: italic; |
8144 |
21 Apr 23 |
nicklas |
263 |
} |
8144 |
21 Apr 23 |
nicklas |
264 |
|
8144 |
21 Apr 23 |
nicklas |
265 |
.interactable.file-column:hover > div:first-child |
8144 |
21 Apr 23 |
nicklas |
266 |
{ |
8144 |
21 Apr 23 |
nicklas |
267 |
padding: 1px 4px 1px 2px; |
8144 |
21 Apr 23 |
nicklas |
268 |
} |
8144 |
21 Apr 23 |
nicklas |
269 |
.interactable.file-column:hover > div.example |
8144 |
21 Apr 23 |
nicklas |
270 |
{ |
8144 |
21 Apr 23 |
nicklas |
271 |
padding: 1px 2px 1px 4px; |
8144 |
21 Apr 23 |
nicklas |
272 |
} |
8144 |
21 Apr 23 |
nicklas |
273 |
|
8144 |
21 Apr 23 |
nicklas |
274 |
.index-only .file-column |
8144 |
21 Apr 23 |
nicklas |
275 |
{ |
8144 |
21 Apr 23 |
nicklas |
276 |
width: 20em; |
8144 |
21 Apr 23 |
nicklas |
277 |
grid-template-columns: 5em 1fr; |
8144 |
21 Apr 23 |
nicklas |
278 |
} |
8144 |
21 Apr 23 |
nicklas |
279 |
|
8144 |
21 Apr 23 |
nicklas |
280 |
.index-only .interactable.file-column:hover |
8144 |
21 Apr 23 |
nicklas |
281 |
{ |
8144 |
21 Apr 23 |
nicklas |
282 |
grid-template-columns: calc(5em - 2px) 1fr; |
8144 |
21 Apr 23 |
nicklas |
283 |
} |
7494 |
04 Jun 18 |
nicklas |
284 |
</style> |
7494 |
04 Jun 18 |
nicklas |
285 |
</base:head> |
5955 |
13 Feb 12 |
nicklas |
286 |
<base:body> |
6021 |
19 Mar 12 |
nicklas |
287 |
<div class="absolutefull bottomborder"> |
6021 |
19 Mar 12 |
nicklas |
288 |
|
5955 |
13 Feb 12 |
nicklas |
289 |
<t:tabcontrol |
5955 |
13 Feb 12 |
nicklas |
290 |
id="parsedFile" |
6021 |
19 Mar 12 |
nicklas |
291 |
subclass="absolutefull dialogtabcontrol" |
6600 |
17 Nov 14 |
nicklas |
292 |
position="top" active="filedata" |
5955 |
13 Feb 12 |
nicklas |
293 |
> |
2655 |
22 Sep 06 |
nicklas |
294 |
<t:tab |
2655 |
22 Sep 06 |
nicklas |
295 |
id="filedata" |
2655 |
22 Sep 06 |
nicklas |
296 |
title="File data" |
2655 |
22 Sep 06 |
nicklas |
297 |
> |
7654 |
15 Mar 19 |
nicklas |
298 |
<div id="waitWhileParsing" class="absolutefull bg-filled-100" style="display: none;"> |
7654 |
15 Mar 19 |
nicklas |
299 |
<div class="messagecontainer error"> |
7654 |
15 Mar 19 |
nicklas |
300 |
Parsing file. Please wait... |
7654 |
15 Mar 19 |
nicklas |
301 |
</div> |
7654 |
15 Mar 19 |
nicklas |
302 |
</div> |
7654 |
15 Mar 19 |
nicklas |
303 |
<div id="myContent"> |
2655 |
22 Sep 06 |
nicklas |
304 |
<% |
2655 |
22 Sep 06 |
nicklas |
305 |
if (file == null) |
2655 |
22 Sep 06 |
nicklas |
306 |
{ |
6607 |
19 Nov 14 |
nicklas |
307 |
%> |
7654 |
15 Mar 19 |
nicklas |
308 |
<div class="absolutefull bg-filled-100"> |
6540 |
26 Sep 14 |
nicklas |
309 |
<div class="messagecontainer error"> |
2655 |
22 Sep 06 |
nicklas |
310 |
No file selected. Please select a file to test above. |
2655 |
22 Sep 06 |
nicklas |
311 |
</div> |
6607 |
19 Nov 14 |
nicklas |
312 |
</div> |
2655 |
22 Sep 06 |
nicklas |
313 |
<% |
2655 |
22 Sep 06 |
nicklas |
314 |
} |
2655 |
22 Sep 06 |
nicklas |
315 |
else |
2655 |
22 Sep 06 |
nicklas |
316 |
{ |
2655 |
22 Sep 06 |
nicklas |
317 |
if (messages.size() > 0) |
2655 |
22 Sep 06 |
nicklas |
318 |
{ |
2655 |
22 Sep 06 |
nicklas |
319 |
%> |
7654 |
15 Mar 19 |
nicklas |
320 |
<div class="bg-filled-100" style="padding: 5px;"> |
6607 |
19 Nov 14 |
nicklas |
321 |
<div class="messagecontainer error" style="margin: 0;"> |
2655 |
22 Sep 06 |
nicklas |
322 |
<b>Could not parse the file <code><%=HTML.encodeTags(path)%></code></b> |
2655 |
22 Sep 06 |
nicklas |
323 |
<ol> |
2655 |
22 Sep 06 |
nicklas |
324 |
<li><%=Values.getString(messages, "<li>", true)%> |
2655 |
22 Sep 06 |
nicklas |
325 |
</ol> |
2655 |
22 Sep 06 |
nicklas |
326 |
</div> |
6607 |
19 Nov 14 |
nicklas |
327 |
</div> |
2655 |
22 Sep 06 |
nicklas |
328 |
<% |
2655 |
22 Sep 06 |
nicklas |
329 |
} |
2655 |
22 Sep 06 |
nicklas |
330 |
%> |
6607 |
19 Nov 14 |
nicklas |
331 |
<div class="itemlist" style="<%=messages.size()==0 ? "" : "border-top-width: 1px;"%>"> |
6607 |
19 Nov 14 |
nicklas |
332 |
<div class="data"> |
7494 |
04 Jun 18 |
nicklas |
333 |
<table style="border: 0;" id="fileData"> |
6607 |
19 Nov 14 |
nicklas |
334 |
<thead class="bg-filled-100"> |
5955 |
13 Feb 12 |
nicklas |
335 |
<tr> |
7661 |
20 Mar 19 |
nicklas |
336 |
<th class="line-no">Line</th> |
7661 |
20 Mar 19 |
nicklas |
337 |
<th class="num-cols">Columns</th> |
7661 |
20 Mar 19 |
nicklas |
338 |
<th class="line-type">Type</th> |
5955 |
13 Feb 12 |
nicklas |
339 |
<th>Use as</th> |
5955 |
13 Feb 12 |
nicklas |
340 |
<th colspan="99">File data</th> |
5955 |
13 Feb 12 |
nicklas |
341 |
</tr> |
5955 |
13 Feb 12 |
nicklas |
342 |
</thead> |
5955 |
13 Feb 12 |
nicklas |
343 |
<tbody class="rows"> |
2655 |
22 Sep 06 |
nicklas |
344 |
|
2655 |
22 Sep 06 |
nicklas |
345 |
<% |
2655 |
22 Sep 06 |
nicklas |
346 |
int currentLine = 0; |
2655 |
22 Sep 06 |
nicklas |
347 |
int headerLines = parser.getLineCount(); |
6607 |
19 Nov 14 |
nicklas |
348 |
String[] rowclass = new String[] { "bg-oddrow", "bg-evenrow" }; |
2655 |
22 Sep 06 |
nicklas |
349 |
int rowClassIndex = 0; |
6200 |
05 Nov 12 |
nicklas |
350 |
|
7494 |
04 Jun 18 |
nicklas |
351 |
while (currentLine < maxLines && currentLine < headerLines) |
2655 |
22 Sep 06 |
nicklas |
352 |
{ |
2655 |
22 Sep 06 |
nicklas |
353 |
FlatFileParser.Line line = parser.getLine(currentLine); |
6200 |
05 Nov 12 |
nicklas |
354 |
linePatterns.add(Pattern.quote(line.line())); |
2655 |
22 Sep 06 |
nicklas |
355 |
String[] data = null; |
7494 |
04 Jun 18 |
nicklas |
356 |
int numMoreColumns = 0; |
2655 |
22 Sep 06 |
nicklas |
357 |
if (line.type() == FlatFileParser.LineType.HEADER) |
2655 |
22 Sep 06 |
nicklas |
358 |
{ |
2655 |
22 Sep 06 |
nicklas |
359 |
data = new String[] { line.name(), line.value() }; |
2655 |
22 Sep 06 |
nicklas |
360 |
} |
2655 |
22 Sep 06 |
nicklas |
361 |
else if (splitter != null) |
2655 |
22 Sep 06 |
nicklas |
362 |
{ |
2655 |
22 Sep 06 |
nicklas |
363 |
data = parser.trimQuotes(splitter.split(line.line(), 99)); |
7494 |
04 Jun 18 |
nicklas |
364 |
if (data.length == 99) |
7494 |
04 Jun 18 |
nicklas |
365 |
{ |
7494 |
04 Jun 18 |
nicklas |
366 |
numMoreColumns = splitter.split(line.line()).length - 99; |
7494 |
04 Jun 18 |
nicklas |
367 |
} |
2655 |
22 Sep 06 |
nicklas |
368 |
} |
2655 |
22 Sep 06 |
nicklas |
369 |
else |
2655 |
22 Sep 06 |
nicklas |
370 |
{ |
2655 |
22 Sep 06 |
nicklas |
371 |
data = new String[] { line.line() }; |
2655 |
22 Sep 06 |
nicklas |
372 |
} |
2655 |
22 Sep 06 |
nicklas |
373 |
%> |
7661 |
20 Mar 19 |
nicklas |
374 |
<tr class="<%=rowclass[rowClassIndex]%> highlight type-<%=line.type().name() %>"> |
7661 |
20 Mar 19 |
nicklas |
375 |
<td class="cell line-no"><%=line.lineNo()%></td> |
7661 |
20 Mar 19 |
nicklas |
376 |
<td class="cell num-cols"><%=data.length+numMoreColumns%></td> |
7661 |
20 Mar 19 |
nicklas |
377 |
<td class="cell line-type"><%=line.type()%></td> |
2655 |
22 Sep 06 |
nicklas |
378 |
<td class="cell"> |
6200 |
05 Nov 12 |
nicklas |
379 |
<select class="auto-init" |
6200 |
05 Nov 12 |
nicklas |
380 |
data-auto-init="line-pattern" |
6200 |
05 Nov 12 |
nicklas |
381 |
data-line-no="<%=currentLine%>"> |
2655 |
22 Sep 06 |
nicklas |
382 |
<option value=""> |
2655 |
22 Sep 06 |
nicklas |
383 |
<option value="dataHeader">Data header |
2655 |
22 Sep 06 |
nicklas |
384 |
<option value="dataFooter">Data footer |
2655 |
22 Sep 06 |
nicklas |
385 |
</select> |
2655 |
22 Sep 06 |
nicklas |
386 |
</td> |
2655 |
22 Sep 06 |
nicklas |
387 |
<% |
6139 |
19 Sep 12 |
nicklas |
388 |
int colNo = 0; |
2655 |
22 Sep 06 |
nicklas |
389 |
for (String d : data) |
2655 |
22 Sep 06 |
nicklas |
390 |
{ |
7975 |
07 Jun 21 |
nicklas |
391 |
String v = HTML.encodeTags(d); |
2655 |
22 Sep 06 |
nicklas |
392 |
%> |
7975 |
07 Jun 21 |
nicklas |
393 |
<td class="cell col-<%=colNo%>" <%=v.length() > 20 ? "title=\""+v+"\"":"" %>><%=v %></td> |
2655 |
22 Sep 06 |
nicklas |
394 |
<% |
6139 |
19 Sep 12 |
nicklas |
395 |
colNo++; |
6139 |
19 Sep 12 |
nicklas |
396 |
if (colNo == 99) break; |
2655 |
22 Sep 06 |
nicklas |
397 |
} |
6139 |
19 Sep 12 |
nicklas |
398 |
if (colNo < 99) |
6139 |
19 Sep 12 |
nicklas |
399 |
{ |
6139 |
19 Sep 12 |
nicklas |
400 |
%> |
6139 |
19 Sep 12 |
nicklas |
401 |
<td class="cell" colspan="<%=99-colNo%>"></td> |
6139 |
19 Sep 12 |
nicklas |
402 |
<% |
6139 |
19 Sep 12 |
nicklas |
403 |
} |
2655 |
22 Sep 06 |
nicklas |
404 |
%> |
2655 |
22 Sep 06 |
nicklas |
405 |
</tr> |
2655 |
22 Sep 06 |
nicklas |
406 |
<% |
2655 |
22 Sep 06 |
nicklas |
407 |
currentLine++; |
2655 |
22 Sep 06 |
nicklas |
408 |
rowClassIndex = 1 - rowClassIndex; |
2655 |
22 Sep 06 |
nicklas |
409 |
} |
2655 |
22 Sep 06 |
nicklas |
410 |
if (currentLine < maxLines) |
2655 |
22 Sep 06 |
nicklas |
411 |
{ |
8144 |
21 Apr 23 |
nicklas |
412 |
if (lastLine == FlatFileParser.LineType.DATA) |
8144 |
21 Apr 23 |
nicklas |
413 |
{ |
8144 |
21 Apr 23 |
nicklas |
414 |
firstDataLine = parser.nextData(); |
8144 |
21 Apr 23 |
nicklas |
415 |
} |
7494 |
04 Jun 18 |
nicklas |
416 |
while (currentLine < maxLines && parser.hasMoreData()) |
2655 |
22 Sep 06 |
nicklas |
417 |
{ |
2655 |
22 Sep 06 |
nicklas |
418 |
FlatFileParser.Data data = parser.nextData(); |
8144 |
21 Apr 23 |
nicklas |
419 |
if (firstDataLine == null) firstDataLine = data; |
6200 |
05 Nov 12 |
nicklas |
420 |
linePatterns.add(Pattern.quote(data.line())); |
2655 |
22 Sep 06 |
nicklas |
421 |
if (parser.getNumSkippedLines() > 0) |
2655 |
22 Sep 06 |
nicklas |
422 |
{ |
2655 |
22 Sep 06 |
nicklas |
423 |
%> |
7661 |
20 Mar 19 |
nicklas |
424 |
<tr class="type-IGNORED"> |
7661 |
20 Mar 19 |
nicklas |
425 |
<td class="bg-filled-100" colspan="103"> |
2655 |
22 Sep 06 |
nicklas |
426 |
Skipped <%=parser.getNumSkippedLines()%> lines |
2655 |
22 Sep 06 |
nicklas |
427 |
(<%=parser.getIgnoredLines()%> ignored; <%=parser.getUnknownLines()%> unknown) |
2655 |
22 Sep 06 |
nicklas |
428 |
</td> |
2655 |
22 Sep 06 |
nicklas |
429 |
</tr> |
2655 |
22 Sep 06 |
nicklas |
430 |
<% |
2655 |
22 Sep 06 |
nicklas |
431 |
} |
2655 |
22 Sep 06 |
nicklas |
432 |
%> |
7661 |
20 Mar 19 |
nicklas |
433 |
<tr class="<%=rowclass[rowClassIndex]%> highlight type-DATA"> |
7661 |
20 Mar 19 |
nicklas |
434 |
<td class="cell line-no"><%=data.lineNo()%></td> |
7661 |
20 Mar 19 |
nicklas |
435 |
<td class="cell num-cols"><%=data.columns()%></td> |
7661 |
20 Mar 19 |
nicklas |
436 |
<td class="cell line-type">Data</td> |
2655 |
22 Sep 06 |
nicklas |
437 |
<td class="cell"> |
6200 |
05 Nov 12 |
nicklas |
438 |
<select class="auto-init" |
6200 |
05 Nov 12 |
nicklas |
439 |
data-auto-init="line-pattern" |
6200 |
05 Nov 12 |
nicklas |
440 |
data-line-no="<%=currentLine%>"> |
2655 |
22 Sep 06 |
nicklas |
441 |
<option value=""> |
2655 |
22 Sep 06 |
nicklas |
442 |
<option value="dataHeader">Data header |
2655 |
22 Sep 06 |
nicklas |
443 |
<option value="dataFooter">Data footer |
2655 |
22 Sep 06 |
nicklas |
444 |
</select> |
2655 |
22 Sep 06 |
nicklas |
445 |
</td> |
2655 |
22 Sep 06 |
nicklas |
446 |
<% |
7494 |
04 Jun 18 |
nicklas |
447 |
for (int i = 0; i < data.columns() && i < 99; ++i) |
2655 |
22 Sep 06 |
nicklas |
448 |
{ |
7975 |
07 Jun 21 |
nicklas |
449 |
String v = HTML.encodeTags(data.getString(i)); |
2655 |
22 Sep 06 |
nicklas |
450 |
%> |
7975 |
07 Jun 21 |
nicklas |
451 |
<td class="cell" <%=v.length() > 20 ? "title=\""+v+"\"":"" %>><%=v%></td> |
2655 |
22 Sep 06 |
nicklas |
452 |
<% |
2655 |
22 Sep 06 |
nicklas |
453 |
} |
6139 |
19 Sep 12 |
nicklas |
454 |
if (data.columns() < 99) |
6139 |
19 Sep 12 |
nicklas |
455 |
{ |
6139 |
19 Sep 12 |
nicklas |
456 |
%> |
6139 |
19 Sep 12 |
nicklas |
457 |
<td class="cell" colspan="<%=99-data.columns()%>"></td> |
6139 |
19 Sep 12 |
nicklas |
458 |
<% |
6139 |
19 Sep 12 |
nicklas |
459 |
} |
2655 |
22 Sep 06 |
nicklas |
460 |
%> |
2655 |
22 Sep 06 |
nicklas |
461 |
</tr> |
2655 |
22 Sep 06 |
nicklas |
462 |
<% |
2655 |
22 Sep 06 |
nicklas |
463 |
currentLine++; |
2655 |
22 Sep 06 |
nicklas |
464 |
rowClassIndex = 1 - rowClassIndex; |
2655 |
22 Sep 06 |
nicklas |
465 |
} |
2655 |
22 Sep 06 |
nicklas |
466 |
if (parser.getNumSkippedLines() > 0) |
2655 |
22 Sep 06 |
nicklas |
467 |
{ |
2655 |
22 Sep 06 |
nicklas |
468 |
%> |
2655 |
22 Sep 06 |
nicklas |
469 |
<tr> |
2655 |
22 Sep 06 |
nicklas |
470 |
<td class="error" colspan="99"> |
2655 |
22 Sep 06 |
nicklas |
471 |
Skipped <%=parser.getNumSkippedLines()%> lines |
2655 |
22 Sep 06 |
nicklas |
472 |
(<%=parser.getIgnoredLines()%> ignored; <%=parser.getUnknownLines()%> unknown) |
2655 |
22 Sep 06 |
nicklas |
473 |
</td> |
2655 |
22 Sep 06 |
nicklas |
474 |
</tr> |
2655 |
22 Sep 06 |
nicklas |
475 |
<% |
2655 |
22 Sep 06 |
nicklas |
476 |
} |
2655 |
22 Sep 06 |
nicklas |
477 |
} |
2655 |
22 Sep 06 |
nicklas |
478 |
%> |
5955 |
13 Feb 12 |
nicklas |
479 |
</tbody> |
5955 |
13 Feb 12 |
nicklas |
480 |
</table> |
5955 |
13 Feb 12 |
nicklas |
481 |
</div> |
5955 |
13 Feb 12 |
nicklas |
482 |
</div> |
2655 |
22 Sep 06 |
nicklas |
483 |
<% |
2655 |
22 Sep 06 |
nicklas |
484 |
} |
2655 |
22 Sep 06 |
nicklas |
485 |
%> |
7654 |
15 Mar 19 |
nicklas |
486 |
</div> |
2655 |
22 Sep 06 |
nicklas |
487 |
</t:tab> |
2655 |
22 Sep 06 |
nicklas |
488 |
|
2655 |
22 Sep 06 |
nicklas |
489 |
<t:tab |
2655 |
22 Sep 06 |
nicklas |
490 |
id="mappings" |
2655 |
22 Sep 06 |
nicklas |
491 |
title="Column mappings" |
3566 |
18 Jul 07 |
nicklas |
492 |
visible="<%=dataIsFound && request.getParameter("mappingParameterNames") != null%>" |
2655 |
22 Sep 06 |
nicklas |
493 |
> |
2655 |
22 Sep 06 |
nicklas |
494 |
<% |
2655 |
22 Sep 06 |
nicklas |
495 |
List<String> headers = parser.getColumnHeaders(); |
8144 |
21 Apr 23 |
nicklas |
496 |
//headers = null; |
2655 |
22 Sep 06 |
nicklas |
497 |
int index = 0; |
8144 |
21 Apr 23 |
nicklas |
498 |
int maxDataColumns = headers != null ? headers.size() : firstDataLine.columns(); |
8144 |
21 Apr 23 |
nicklas |
499 |
%> |
8144 |
21 Apr 23 |
nicklas |
500 |
<div id="predefinedColumnMappings" class="menu vertical bg-filled-100 <%=headers==null?"index-only":"" %>" style="display: none;"> |
8144 |
21 Apr 23 |
nicklas |
501 |
<div class="menuitem file-column" style="font-weight: bold;"> |
8144 |
21 Apr 23 |
nicklas |
502 |
<div>Column</div> |
8144 |
21 Apr 23 |
nicklas |
503 |
<div class="example">Example</div> |
8144 |
21 Apr 23 |
nicklas |
504 |
</div> |
8144 |
21 Apr 23 |
nicklas |
505 |
<% |
4347 |
18 Jun 08 |
nicklas |
506 |
while (index < maxDataColumns) |
4347 |
18 Jun 08 |
nicklas |
507 |
{ |
8144 |
21 Apr 23 |
nicklas |
508 |
String headerText = headers != null ? HTML.encodeTags(headers.get(index)) : ""; |
8144 |
21 Apr 23 |
nicklas |
509 |
String exampleText = HTML.encodeTags(firstDataLine.getString(index)); |
8144 |
21 Apr 23 |
nicklas |
510 |
%> |
8144 |
21 Apr 23 |
nicklas |
511 |
<div class="menuitem interactable file-column auto-init" |
8144 |
21 Apr 23 |
nicklas |
512 |
data-auto-init="preset-column-mapping" data-index="<%=index%>" |
8144 |
21 Apr 23 |
nicklas |
513 |
title="<%=headerText%> – <%=exampleText%>" |
8144 |
21 Apr 23 |
nicklas |
514 |
> |
8144 |
21 Apr 23 |
nicklas |
515 |
<div><%=Integer.toString(index+1)%>: <%=headerText%></div> |
8144 |
21 Apr 23 |
nicklas |
516 |
<div class="example"><%=exampleText%></div> |
8144 |
21 Apr 23 |
nicklas |
517 |
</div> |
8144 |
21 Apr 23 |
nicklas |
518 |
<% |
4347 |
18 Jun 08 |
nicklas |
519 |
index++; |
4347 |
18 Jun 08 |
nicklas |
520 |
} |
8144 |
21 Apr 23 |
nicklas |
521 |
%> |
8144 |
21 Apr 23 |
nicklas |
522 |
</div> |
8144 |
21 Apr 23 |
nicklas |
523 |
<% |
4419 |
27 Aug 08 |
nicklas |
524 |
String[] mappingParameters = request.getParameter("mappingParameterNames").split(","); |
6200 |
05 Nov 12 |
nicklas |
525 |
if (headers != null) |
4419 |
27 Aug 08 |
nicklas |
526 |
{ |
6200 |
05 Nov 12 |
nicklas |
527 |
List<String> labels = new ArrayList<String>(); |
6200 |
05 Nov 12 |
nicklas |
528 |
for (String name : mappingParameters) |
6200 |
05 Nov 12 |
nicklas |
529 |
{ |
6200 |
05 Nov 12 |
nicklas |
530 |
labels.add(request.getParameter("mapping." + name + ".label")); |
6200 |
05 Nov 12 |
nicklas |
531 |
} |
6200 |
05 Nov 12 |
nicklas |
532 |
StringMatcher sm = new StringMatcher(); |
6200 |
05 Nov 12 |
nicklas |
533 |
List<FuzzyMatch> matches = sm.getBestPairs(labels, headers); |
4419 |
27 Aug 08 |
nicklas |
534 |
int i = 0; |
4419 |
27 Aug 08 |
nicklas |
535 |
for (FuzzyMatch fm : matches) |
4419 |
27 Aug 08 |
nicklas |
536 |
{ |
4419 |
27 Aug 08 |
nicklas |
537 |
String name = mappingParameters[i]; |
4419 |
27 Aug 08 |
nicklas |
538 |
if (fm != null) |
4419 |
27 Aug 08 |
nicklas |
539 |
{ |
6200 |
05 Nov 12 |
nicklas |
540 |
JSONObject jsonFuzzyMatch = new JSONObject(); |
6200 |
05 Nov 12 |
nicklas |
541 |
jsonFuzzyMatch.put("name", mappingParameters[i]); |
6200 |
05 Nov 12 |
nicklas |
542 |
jsonFuzzyMatch.put("columnIndex", headers.indexOf(fm.getValue())); |
6200 |
05 Nov 12 |
nicklas |
543 |
jsonFuzzyMatch.put("score", fm.getScore()); |
6200 |
05 Nov 12 |
nicklas |
544 |
jsonFuzzy.add(jsonFuzzyMatch); |
4419 |
27 Aug 08 |
nicklas |
545 |
} |
4419 |
27 Aug 08 |
nicklas |
546 |
else |
4419 |
27 Aug 08 |
nicklas |
547 |
{ |
6200 |
05 Nov 12 |
nicklas |
548 |
jsonFuzzy.add(null); |
4419 |
27 Aug 08 |
nicklas |
549 |
} |
4419 |
27 Aug 08 |
nicklas |
550 |
++i; |
4419 |
27 Aug 08 |
nicklas |
551 |
} |
4419 |
27 Aug 08 |
nicklas |
552 |
} |
4419 |
27 Aug 08 |
nicklas |
553 |
%> |
2655 |
22 Sep 06 |
nicklas |
554 |
<form name="mappings"> |
6621 |
24 Nov 14 |
nicklas |
555 |
<div class="absolutefull bg-filled-100" style="height: 2em;"> |
5955 |
13 Feb 12 |
nicklas |
556 |
<table> |
2655 |
22 Sep 06 |
nicklas |
557 |
<tr> |
6621 |
24 Nov 14 |
nicklas |
558 |
<td style="padding-left: 4px;"> |
5955 |
13 Feb 12 |
nicklas |
559 |
<b>Mapping style:</b> |
5955 |
13 Feb 12 |
nicklas |
560 |
<input type="radio" name="expressionStyle" id="expressionStyleSimple" value="1" checked><label for="expressionStyleSimple">Simple</label> |
5955 |
13 Feb 12 |
nicklas |
561 |
<input type="radio" name="expressionStyle" id="expressionStyleExpression" value="2"><label for="expressionStyleExpression">Expression</label> |
5955 |
13 Feb 12 |
nicklas |
562 |
</td> |
5955 |
13 Feb 12 |
nicklas |
563 |
<% |
6200 |
05 Nov 12 |
nicklas |
564 |
if (jsonFuzzy.size() > 0) |
5955 |
13 Feb 12 |
nicklas |
565 |
{ |
5955 |
13 Feb 12 |
nicklas |
566 |
%> |
7662 |
20 Mar 19 |
nicklas |
567 |
<td style="padding-left: 1em;"> |
6200 |
05 Nov 12 |
nicklas |
568 |
<base:button id="btnFuzzyMatches" title="Auto generate" |
5955 |
13 Feb 12 |
nicklas |
569 |
tooltip="Generate mappings by finding the best match between Property and File column"/> |
6200 |
05 Nov 12 |
nicklas |
570 |
Similarity score: |
7662 |
20 Mar 19 |
nicklas |
571 |
<input type="text" id="similarityScore" name="similarity" value="0.85" style="width: 4em;"> |
5955 |
13 Feb 12 |
nicklas |
572 |
(0 = bad; 1 = good) |
5955 |
13 Feb 12 |
nicklas |
573 |
</td> |
7662 |
20 Mar 19 |
nicklas |
574 |
<td style="padding-left: 1em;"> |
7662 |
20 Mar 19 |
nicklas |
575 |
<label><input type="checkbox" name="overwrite" checked>Overwrite existing mappings</label> |
7662 |
20 Mar 19 |
nicklas |
576 |
</td> |
5955 |
13 Feb 12 |
nicklas |
577 |
<% |
5955 |
13 Feb 12 |
nicklas |
578 |
} |
5955 |
13 Feb 12 |
nicklas |
579 |
%> |
2655 |
22 Sep 06 |
nicklas |
580 |
</tr> |
5955 |
13 Feb 12 |
nicklas |
581 |
</table> |
5955 |
13 Feb 12 |
nicklas |
582 |
</div> |
5955 |
13 Feb 12 |
nicklas |
583 |
|
6684 |
14 Jan 15 |
nicklas |
584 |
<div class="absolutefull input100" style="top: 2em;"> |
5955 |
13 Feb 12 |
nicklas |
585 |
|
6684 |
14 Jan 15 |
nicklas |
586 |
<tbl:table id="col-mappings"> |
6684 |
14 Jan 15 |
nicklas |
587 |
<tbl:columndef |
6684 |
14 Jan 15 |
nicklas |
588 |
id="property" |
6684 |
14 Jan 15 |
nicklas |
589 |
title="Property" |
6684 |
14 Jan 15 |
nicklas |
590 |
/> |
6684 |
14 Jan 15 |
nicklas |
591 |
<tbl:columndef |
6684 |
14 Jan 15 |
nicklas |
592 |
id="expression" |
6684 |
14 Jan 15 |
nicklas |
593 |
title="Mapping expression" |
6684 |
14 Jan 15 |
nicklas |
594 |
/> |
6684 |
14 Jan 15 |
nicklas |
595 |
<tbl:columndef |
6684 |
14 Jan 15 |
nicklas |
596 |
id="columns" |
6684 |
14 Jan 15 |
nicklas |
597 |
title="File columns" |
6684 |
14 Jan 15 |
nicklas |
598 |
/> |
6684 |
14 Jan 15 |
nicklas |
599 |
<tbl:data> |
6684 |
14 Jan 15 |
nicklas |
600 |
<tbl:headers> |
6684 |
14 Jan 15 |
nicklas |
601 |
<tbl:headerrow> |
6684 |
14 Jan 15 |
nicklas |
602 |
<tbl:columnheaders /> |
6684 |
14 Jan 15 |
nicklas |
603 |
</tbl:headerrow> |
6684 |
14 Jan 15 |
nicklas |
604 |
</tbl:headers> |
6684 |
14 Jan 15 |
nicklas |
605 |
<tbl:rows> |
6684 |
14 Jan 15 |
nicklas |
606 |
<% |
6684 |
14 Jan 15 |
nicklas |
607 |
for (String name : mappingParameters) |
6684 |
14 Jan 15 |
nicklas |
608 |
{ |
6684 |
14 Jan 15 |
nicklas |
609 |
%> |
6684 |
14 Jan 15 |
nicklas |
610 |
<tbl:row> |
6684 |
14 Jan 15 |
nicklas |
611 |
<tbl:cell column="property"><%=HTML.encodeTags(request.getParameter("mapping." + name + ".label"))%></tbl:cell> |
6684 |
14 Jan 15 |
nicklas |
612 |
<tbl:cell column="expression"> |
6684 |
14 Jan 15 |
nicklas |
613 |
|
6684 |
14 Jan 15 |
nicklas |
614 |
<table style="width: 100%;"> |
6684 |
14 Jan 15 |
nicklas |
615 |
<tr> |
6684 |
14 Jan 15 |
nicklas |
616 |
<td> |
6684 |
14 Jan 15 |
nicklas |
617 |
<input type="text" class="text auto-init" data-auto-init="column-mapping" |
6684 |
14 Jan 15 |
nicklas |
618 |
name="mapping.<%=name%>.expression" |
6684 |
14 Jan 15 |
nicklas |
619 |
maxlength="80" |
6684 |
14 Jan 15 |
nicklas |
620 |
value="<%=HTML.encodeTags(request.getParameter("mapping." + name + ".expression"))%>"> |
6684 |
14 Jan 15 |
nicklas |
621 |
</td> |
6684 |
14 Jan 15 |
nicklas |
622 |
<td style="width: 22px;"> |
6684 |
14 Jan 15 |
nicklas |
623 |
<base:icon image="cancel.png" subclass="auto-init" id="<%="clear."+name %>" |
6684 |
14 Jan 15 |
nicklas |
624 |
data-auto-init="column-mapping-clear" data-mapping="<%=name%>" |
6684 |
14 Jan 15 |
nicklas |
625 |
tooltip="Clear this expression"/> |
6684 |
14 Jan 15 |
nicklas |
626 |
</td> |
6684 |
14 Jan 15 |
nicklas |
627 |
</tr> |
6684 |
14 Jan 15 |
nicklas |
628 |
</table> |
6684 |
14 Jan 15 |
nicklas |
629 |
</tbl:cell> |
6684 |
14 Jan 15 |
nicklas |
630 |
|
6684 |
14 Jan 15 |
nicklas |
631 |
<tbl:cell column="columns"> |
8144 |
21 Apr 23 |
nicklas |
632 |
<base:button |
8144 |
21 Apr 23 |
nicklas |
633 |
title="- select -" image="mini_scroll_down.png" |
8144 |
21 Apr 23 |
nicklas |
634 |
subclass="icon-to-right auto-init" style="font-style: italic;" |
8144 |
21 Apr 23 |
nicklas |
635 |
data-auto-init="column-mapping-preset-menu" |
8144 |
21 Apr 23 |
nicklas |
636 |
data-mapping="<%=name%>" |
8144 |
21 Apr 23 |
nicklas |
637 |
/> |
6684 |
14 Jan 15 |
nicklas |
638 |
</tbl:cell> |
6684 |
14 Jan 15 |
nicklas |
639 |
|
6684 |
14 Jan 15 |
nicklas |
640 |
</tbl:row> |
6684 |
14 Jan 15 |
nicklas |
641 |
<% |
6684 |
14 Jan 15 |
nicklas |
642 |
} |
6684 |
14 Jan 15 |
nicklas |
643 |
%> |
6684 |
14 Jan 15 |
nicklas |
644 |
</tbl:rows> |
6684 |
14 Jan 15 |
nicklas |
645 |
</tbl:data> |
6684 |
14 Jan 15 |
nicklas |
646 |
</tbl:table> |
5955 |
13 Feb 12 |
nicklas |
647 |
</div> |
5955 |
13 Feb 12 |
nicklas |
648 |
</form> |
2655 |
22 Sep 06 |
nicklas |
649 |
</t:tab> |
2655 |
22 Sep 06 |
nicklas |
650 |
|
2655 |
22 Sep 06 |
nicklas |
651 |
</t:tabcontrol> |
6200 |
05 Nov 12 |
nicklas |
652 |
|
6200 |
05 Nov 12 |
nicklas |
653 |
<div id="page-data" class="datacontainer" |
6200 |
05 Nov 12 |
nicklas |
654 |
data-line-patterns="<%=HTML.encodeTags(linePatterns.toJSONString())%>" |
6200 |
05 Nov 12 |
nicklas |
655 |
<% |
6200 |
05 Nov 12 |
nicklas |
656 |
if (parser != null && parser.getColumnHeaders() != null) |
6200 |
05 Nov 12 |
nicklas |
657 |
{ |
6200 |
05 Nov 12 |
nicklas |
658 |
%> |
6200 |
05 Nov 12 |
nicklas |
659 |
data-column-headers="<%=HTML.encodeTags(JSONArray.toJSONString(parser.getColumnHeaders())) %>" |
6200 |
05 Nov 12 |
nicklas |
660 |
<% |
6200 |
05 Nov 12 |
nicklas |
661 |
} |
6200 |
05 Nov 12 |
nicklas |
662 |
%> |
6200 |
05 Nov 12 |
nicklas |
663 |
data-fuzzy-matches="<%=HTML.encodeTags(jsonFuzzy.toJSONString()) %>" |
6200 |
05 Nov 12 |
nicklas |
664 |
></div> |
6021 |
19 Mar 12 |
nicklas |
665 |
</div> |
2655 |
22 Sep 06 |
nicklas |
666 |
</base:body> |
2655 |
22 Sep 06 |
nicklas |
667 |
</base:page> |
2655 |
22 Sep 06 |
nicklas |
668 |
<% |
2655 |
22 Sep 06 |
nicklas |
669 |
} |
2655 |
22 Sep 06 |
nicklas |
670 |
finally |
2655 |
22 Sep 06 |
nicklas |
671 |
{ |
2655 |
22 Sep 06 |
nicklas |
672 |
if (fileInputStream != null) fileInputStream.close(); |
2655 |
22 Sep 06 |
nicklas |
673 |
if (dc != null) dc.close(); |
2655 |
22 Sep 06 |
nicklas |
674 |
} |
2655 |
22 Sep 06 |
nicklas |
675 |
%> |
2655 |
22 Sep 06 |
nicklas |
676 |
|