Skip to content
GitLab
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
8fab901d
Commit
8fab901d
authored
Sep 11, 2014
by
igoshin
Committed by
Matija Obreza
Sep 10, 2014
Browse files
Column configuration
parent
a09aed07
Changes
2
Hide whitespace changes
Inline
Side-by-side
anno-gui/src/main/java/org/genesys2/anno/gui/DwcaBuilder.java
View file @
8fab901d
/**
* Copyright 2014 Global Crop Diversity Trust
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
...
@@ -24,15 +24,23 @@ import java.io.IOException;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.genesys2.anno.model.*
;
import
org.genesys2.anno.model.Column
;
import
org.genesys2.anno.model.ColumnDataType
;
import
org.genesys2.anno.model.DatabaseSettings
;
import
org.genesys2.anno.model.OAuthSettings
;
import
org.genesys2.anno.model.Settings
;
import
org.genesys2.anno.parser.CsvDataSourceSheet
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONTokener
;
import
org.springframework.beans.factory.annotation.Autowired
;
public
class
DwcaBuilder
extends
AbstractModelObject
{
@Autowired
private
DataSourceLoader
dataSourceLoader
;
private
List
<
IDataSource
>
fileRoots
=
new
ArrayList
<
IDataSource
>();
private
String
workspaceFilename
=
null
;
...
...
@@ -235,8 +243,19 @@ public class DwcaBuilder extends AbstractModelObject {
JSONArray
columns
=
sheetJ
.
getJSONArray
(
"columns"
);
List
<
Column
>
columnList
=
new
ArrayList
<
Column
>();
for
(
int
x
=
0
;
x
<
columns
.
length
();
x
++)
{
JSONObject
column
=
columns
.
getJSONObject
(
x
);
List
<
Object
[]>
rows
=
null
;
try
{
rows
=
dataSourceLoader
.
loadRows
(
sourceSheet
,
200
);
}
catch
(
UnsupportedDataFormatException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
sourceSheet
.
updateData
(
rows
);
List
<
Column
>
loadedColumns
=
sourceSheet
.
getColumns
();
for
(
int
x
=
0
;
x
<
columns
.
length
();
x
++)
{
JSONObject
column
=
columns
.
getJSONObject
(
x
);
Column
sourceColumn
=
new
Column
();
...
...
@@ -257,11 +276,20 @@ public class DwcaBuilder extends AbstractModelObject {
if
(
column
.
has
(
"multiple"
))
sourceColumn
.
setMultiple
(
column
.
getBoolean
(
"multiple"
));
columnList
.
add
(
sourceColumn
);
}
sourceSheet
.
setColumns
(
columnList
);
sourceSheetList
.
add
(
sourceSheet
);
}
if
(
loadedColumns
.
contains
(
sourceColumn
)){
columnList
.
add
(
sourceColumn
);
}
}
for
(
Column
loadedColumn:
loadedColumns
){
if
(!
columnList
.
contains
(
loadedColumn
)){
columnList
.
add
(
loadedColumns
.
indexOf
(
loadedColumn
),
loadedColumn
);
}
}
sourceSheet
.
setColumns
(
columnList
);
sourceSheetList
.
add
(
sourceSheet
);
}
sourceFile
.
setSheets
(
sourceSheetList
);
...
...
anno-gui/src/main/java/org/genesys2/anno/model/Column.java
View file @
8fab901d
...
...
@@ -120,4 +120,18 @@ public class Column extends AbstractModelObject {
this
.
groupPattern
=
groupPattern
;
firePropertyChange
(
"groupPattern"
,
null
,
this
.
groupPattern
);
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Column
column
=
(
Column
)
o
;
if
(
preferredName
!=
null
?
!
preferredName
.
equals
(
column
.
preferredName
)
:
column
.
preferredName
!=
null
)
return
false
;
return
true
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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