Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Uploader
Commits
f1441c02
Commit
f1441c02
authored
Nov 21, 2014
by
Matija Obreza
Browse files
Include null valued columns
parent
e36382d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
anno-gui/src/main/java/org/genesys2/anno/converter/RowConverter.java
View file @
f1441c02
...
...
@@ -43,17 +43,21 @@ public class RowConverter {
List
<
Column
>
columns
=
dataSourceSheet
.
getColumns
();
for
(
int
i
=
0
;
i
<
columns
.
size
();
i
++)
{
if
(
i
>=
row
.
length
)
{
_log
.
warn
(
"Row has less than "
+
(
i
+
1
)
+
" columns: len="
+
row
.
length
+
" "
+
ArrayUtils
.
toString
(
row
));
continue
;
}
Column
column
=
columns
.
get
(
i
);
ColumnDef
columnDef
=
findColumnDef
(
column
,
columnDefs
.
getColumnDefs
());
if
(
columnDef
==
null
)
{
continue
;
}
if
(
i
>=
row
.
length
)
{
if
(
column
.
isIncludeNull
())
{
map
.
put
(
columnDef
.
getRdfTerm
(),
null
);
}
_log
.
debug
(
"Row has less than "
+
(
i
+
1
)
+
" columns: len="
+
row
.
length
+
" "
+
ArrayUtils
.
toString
(
row
));
continue
;
}
Object
rowValue
=
convertCellValue
(
row
[
i
],
column
.
isMultiple
(),
column
.
getSeparator
(),
column
.
getPattern
(),
column
.
getGroupPattern
());
Object
mapValue
=
map
.
get
(
columnDef
.
getRdfTerm
());
...
...
@@ -83,6 +87,10 @@ public class RowConverter {
newVal
.
add
(
rowValue
);
}
map
.
put
(
columnDef
.
getRdfTerm
(),
newVal
);
}
else
if
(
rowValue
==
null
)
{
if
(
column
.
isIncludeNull
())
{
map
.
put
(
columnDef
.
getRdfTerm
(),
null
);
}
}
}
...
...
@@ -227,7 +235,7 @@ public class RowConverter {
}
if
(
rdfValues
==
null
)
{
// skip
containerNode
.
set
(
fieldName
,
null
);
}
else
if
(
rdfValues
instanceof
ArrayList
<?>)
{
ArrayNode
arrayNode
=
(
ArrayNode
)
valueNode
;
for
(
String
rdfValue
:
(
ArrayList
<
String
>)
rdfValues
)
{
...
...
anno-gui/src/main/java/org/genesys2/anno/gui/SheetDisplay.java
View file @
f1441c02
...
...
@@ -85,6 +85,7 @@ import swing2swt.layout.BorderLayout;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
org.eclipse.core.databinding.beans.PojoProperties
;
@Scope
(
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
public
class
SheetDisplay
extends
Composite
{
...
...
@@ -162,6 +163,7 @@ public class SheetDisplay extends Composite {
private
Text
txtGroupPattern
;
private
Text
txtQueryName
;
private
IDataSource
dataSource
;
private
Button
btnIncludeNullValues
;
/**
* Create the composite.
...
...
@@ -359,6 +361,12 @@ public class SheetDisplay extends Composite {
txtGroupPattern
=
new
Text
(
composite
,
SWT
.
BORDER
);
txtGroupPattern
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
1
,
1
));
new
Label
(
composite
,
SWT
.
NONE
);
btnIncludeNullValues
=
new
Button
(
composite
,
SWT
.
CHECK
);
btnIncludeNullValues
.
setText
(
"Include null values"
);
new
Label
(
composite
,
SWT
.
NONE
);
new
Label
(
composite
,
SWT
.
NONE
);
dropTarget
.
addDropListener
(
new
DropTargetAdapter
()
{
@Override
...
...
@@ -645,16 +653,15 @@ public class SheetDisplay extends Composite {
bindingContext
.
bindValue
(
observeTextTxtCsvQuoteCharObserveWidget
,
dataSourceSheetsheetQuoteCharDswObserveValue
,
null
,
null
);
}
protected
DataBindingContext
initDataBindings
()
{
DataBindingContext
bindingContext
=
new
DataBindingContext
();
//
IObservableValue
observeSelectionChkbxContainsHeadersObserveWidget_1
=
WidgetProperties
.
selection
().
observe
(
chkbxContainsHeaders
);
IObservableValue
headersIncludedGetDataSourceSheetObserveValue
=
Bean
Properties
.
value
(
"dataSourceSheet.headersIncluded"
).
observe
(
dsw
);
IObservableValue
headersIncludedGetDataSourceSheetObserveValue
=
Pojo
Properties
.
value
(
"dataSourceSheet.headersIncluded"
).
observe
(
dsw
);
bindingContext
.
bindValue
(
observeSelectionChkbxContainsHeadersObserveWidget_1
,
headersIncludedGetDataSourceSheetObserveValue
,
null
,
null
);
//
IObservableValue
observeTextTxtHeaderRowIndexObserveWidget_1
=
WidgetProperties
.
text
(
SWT
.
Modify
).
observe
(
txtHeaderRowIndex
);
IObservableValue
headerRowIndexGetDataSourceSheetObserveValue
=
Bean
Properties
.
value
(
"dataSourceSheet.headerRowIndex"
).
observe
(
dsw
);
IObservableValue
headerRowIndexGetDataSourceSheetObserveValue
=
Pojo
Properties
.
value
(
"dataSourceSheet.headerRowIndex"
).
observe
(
dsw
);
bindingContext
.
bindValue
(
observeTextTxtHeaderRowIndexObserveWidget_1
,
headerRowIndexGetDataSourceSheetObserveValue
,
null
,
null
);
//
IObservableValue
observeEnabledTxtHeaderRowIndexObserveWidget
=
WidgetProperties
.
enabled
().
observe
(
txtHeaderRowIndex
);
...
...
@@ -693,6 +700,10 @@ public class SheetDisplay extends Composite {
IObservableValue
selectedColumngroupPatternDswObserveValue
=
BeanProperties
.
value
(
"selectedColumn.groupPattern"
).
observe
(
dsw
);
bindingContext
.
bindValue
(
observeTextTxtGroupPatternObserveWidget
,
selectedColumngroupPatternDswObserveValue
,
null
,
null
);
//
IObservableValue
observeSelectionBtnIncludeNullValuesObserveWidget
=
WidgetProperties
.
selection
().
observe
(
btnIncludeNullValues
);
IObservableValue
selectedColumnincludeNullDswObserveValue
=
BeanProperties
.
value
(
"selectedColumn.includeNull"
).
observe
(
dsw
);
bindingContext
.
bindValue
(
observeSelectionBtnIncludeNullValuesObserveWidget
,
selectedColumnincludeNullDswObserveValue
,
null
,
null
);
//
return
bindingContext
;
}
}
anno-gui/src/main/java/org/genesys2/anno/model/Column.java
View file @
f1441c02
...
...
@@ -28,6 +28,7 @@ public class Column extends AbstractModelObject {
private
String
separator
=
";"
;
private
String
pattern
;
private
String
groupPattern
;
private
boolean
includeNull
=
false
;
public
Column
()
{
}
...
...
@@ -121,17 +122,31 @@ public class Column extends AbstractModelObject {
firePropertyChange
(
"groupPattern"
,
null
,
this
.
groupPattern
);
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
public
void
setIncludeNull
(
boolean
includeNull
)
{
this
.
includeNull
=
includeNull
;
}
public
boolean
isIncludeNull
()
{
return
includeNull
;
}
Column
column
=
(
Column
)
o
;
public
boolean
getIncludeNull
()
{
return
includeNull
;
}
if
(
preferredName
!=
null
?
!
preferredName
.
equals
(
column
.
preferredName
)
:
column
.
preferredName
!=
null
)
return
false
;
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
return
true
;
}
Column
column
=
(
Column
)
o
;
if
(
preferredName
!=
null
?
!
preferredName
.
equals
(
column
.
preferredName
)
:
column
.
preferredName
!=
null
)
return
false
;
return
true
;
}
}
anno-gui/src/main/java/org/genesys2/anno/parser/XlsxRowReader.java
View file @
f1441c02
...
...
@@ -10,7 +10,6 @@ import java.util.Queue;
import
java.util.concurrent.LinkedBlockingQueue
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang3.RandomStringUtils
;
import
org.apache.log4j.Logger
;
import
org.apache.poi.openxml4j.exceptions.InvalidFormatException
;
import
org.apache.poi.openxml4j.exceptions.OpenXML4JException
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment