Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
Uploader
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Uploader
Commits
6c8ce659
Commit
6c8ce659
authored
Jul 09, 2019
by
Viacheslav Pavlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Settings: ignored INSTCODEs
parent
ea595759
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
279 additions
and
4 deletions
+279
-4
anno-gui/src/main/java/org/genesys2/anno/gui/AppWindow.java
anno-gui/src/main/java/org/genesys2/anno/gui/AppWindow.java
+10
-0
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
+14
-2
anno-gui/src/main/java/org/genesys2/anno/gui/SettingsDialog.java
...i/src/main/java/org/genesys2/anno/gui/SettingsDialog.java
+159
-0
anno-gui/src/main/java/org/genesys2/anno/model/InstCodeSettings.java
...c/main/java/org/genesys2/anno/model/InstCodeSettings.java
+59
-0
anno-gui/src/main/java/org/genesys2/anno/model/LoadableSettings.java
...c/main/java/org/genesys2/anno/model/LoadableSettings.java
+12
-0
anno-gui/src/main/java/org/genesys2/anno/model/Settings.java
anno-gui/src/main/java/org/genesys2/anno/model/Settings.java
+25
-2
No files found.
anno-gui/src/main/java/org/genesys2/anno/gui/AppWindow.java
View file @
6c8ce659
...
...
@@ -82,6 +82,7 @@ import org.genesys2.anno.model.ColumnDef;
import
org.genesys2.anno.model.Settings
;
import
org.json.JSONException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
...
@@ -109,6 +110,9 @@ public class AppWindow {
@Autowired
private
Settings
settings
;
@Value
(
"${genesys.magic.workspace}"
)
protected
String
workspacePath
;
private
ExecutorService
threadPool
=
Executors
.
newFixedThreadPool
(
4
);
...
...
@@ -305,6 +309,12 @@ public class AppWindow {
createContents
();
shlGenesysMagic
.
open
();
shlGenesysMagic
.
layout
();
try
{
System
.
err
.
println
(
"Trying to load props"
);
settings
.
load
(
workspacePath
+
"/local.properties"
);
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Failed to load props: "
+
e
.
getMessage
());
}
while
(!
shlGenesysMagic
.
isDisposed
())
{
if
(!
display
.
readAndDispatch
())
{
...
...
anno-gui/src/main/java/org/genesys2/anno/gui/PushDialog.java
View file @
6c8ce659
...
...
@@ -432,6 +432,8 @@ public class PushDialog extends Dialog {
if
(
count
%
100
==
0
)
_log
.
debug
(
"Examining data at row "
+
count
);
final
Set
<
String
>
instCodesFilter
=
settings
.
getInstCodeSettings
().
getInstCodes
();
final
boolean
isBlackList
=
settings
.
getInstCodeSettings
().
isBlackList
();
for
(
Object
[]
row
:
rows
)
{
count
++;
...
...
@@ -442,6 +444,14 @@ public class PushDialog extends Dialog {
// Check for instCode
accnJson
.
get
(
Api1Constants
.
Accession
.
INSTCODE
).
textValue
();
final
String
accessionInstCode
=
(
String
)
accnMap
.
get
(
RdfMCPD
.
INSTCODE
);
// If filtering, check INSTCODE is listed
if
(
instCodesFilter
.
size
()
>
0
&&
!(
isBlackList
^
instCodesFilter
.
contains
(
accessionInstCode
)))
{
_log
.
info
(
"Ignoring accessions with inst code : "
+
accessionInstCode
);
continue
;
}
}
catch
(
Throwable
e
)
{
_log
.
info
(
"Error in row "
+
count
+
". "
+
e
.
getMessage
()
+
": "
+
ArrayUtils
.
toString
(
row
));
}
...
...
@@ -618,7 +628,8 @@ public class PushDialog extends Dialog {
genesysClient
.
me
();
// Filter only for specific INSTCODES
final
Set
<
String
>
instCodesFilter
=
new
HashSet
<>();
final
Set
<
String
>
instCodesFilter
=
settings
.
getInstCodeSettings
().
getInstCodes
();
final
boolean
isBlackList
=
settings
.
getInstCodeSettings
().
isBlackList
();
_log
.
warn
(
"Running upload for "
+
instCodesFilter
.
toString
());
...
...
@@ -664,7 +675,8 @@ public class PushDialog extends Dialog {
final
String
accessionInstCode
=
(
String
)
accnMap
.
get
(
RdfMCPD
.
INSTCODE
);
// If filtering, check INSTCODE is listed
if
(
instCodesFilter
.
size
()
>
0
&&
!
instCodesFilter
.
contains
(
accessionInstCode
))
{
if
(
instCodesFilter
.
size
()
>
0
&&
!(
isBlackList
^
instCodesFilter
.
contains
(
accessionInstCode
)))
{
_log
.
info
(
"Ignoring accessions with inst code : "
+
accessionInstCode
);
continue
;
}
...
...
anno-gui/src/main/java/org/genesys2/anno/gui/SettingsDialog.java
View file @
6c8ce659
...
...
@@ -26,6 +26,8 @@ import org.eclipse.swt.SWT;
import
org.eclipse.swt.custom.ScrolledComposite
;
import
org.eclipse.swt.events.FocusAdapter
;
import
org.eclipse.swt.events.FocusEvent
;
import
org.eclipse.swt.events.KeyAdapter
;
import
org.eclipse.swt.events.KeyEvent
;
import
org.eclipse.swt.events.SelectionAdapter
;
import
org.eclipse.swt.events.SelectionEvent
;
import
org.eclipse.swt.layout.GridData
;
...
...
@@ -33,14 +35,18 @@ import org.eclipse.swt.layout.GridLayout;
import
org.eclipse.swt.layout.RowLayout
;
import
org.eclipse.swt.widgets.Button
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.Dialog
;
import
org.eclipse.swt.widgets.Display
;
import
org.eclipse.swt.widgets.Event
;
import
org.eclipse.swt.widgets.Group
;
import
org.eclipse.swt.widgets.Label
;
import
org.eclipse.swt.widgets.Listener
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.swt.widgets.TabFolder
;
import
org.eclipse.swt.widgets.TabItem
;
import
org.eclipse.swt.widgets.Text
;
import
org.genesys2.anno.model.InstCodeSettings
;
import
org.genesys2.anno.model.OAuthSettings
;
import
org.genesys2.anno.model.Settings
;
import
org.genesys2.client.oauth.GenesysApiException
;
...
...
@@ -50,9 +56,12 @@ import org.genesys2.client.oauth.OAuthAuthenticationException;
import
org.genesys2.client.oauth.PleaseRetryException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
swing2swt.layout.BorderLayout
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.Set
;
public
class
SettingsDialog
extends
Dialog
{
...
...
@@ -66,6 +75,9 @@ public class SettingsDialog extends Dialog {
private
static
final
Logger
_log
=
Logger
.
getLogger
(
SettingsDialog
.
class
);
private
DataBindingContext
m_bindingContext
;
@Value
(
"${genesys.magic.workspace}"
)
protected
String
workspacePath
;
@Autowired
private
Settings
settings
;
...
...
@@ -80,6 +92,8 @@ public class SettingsDialog extends Dialog {
private
Text
txtClientKey
;
private
Text
txtClientSecret
;
private
Text
txtScope
;
private
Text
txtInstCodesToIgnore
;
private
Composite
grpInstCodes
;
/**
* Create the dialog.
...
...
@@ -125,6 +139,7 @@ public class SettingsDialog extends Dialog {
TabItem
tbtmGenesysApi
=
new
TabItem
(
tabFolder
,
SWT
.
NONE
);
tbtmGenesysApi
.
setText
(
"Genesys API"
);
renderAdvancedSection
(
tabFolder
);
ScrolledComposite
scrolledComposite
=
new
ScrolledComposite
(
tabFolder
,
SWT
.
V_SCROLL
);
scrolledComposite
.
setShowFocusedControl
(
true
);
tbtmGenesysApi
.
setControl
(
scrolledComposite
);
...
...
@@ -178,6 +193,150 @@ public class SettingsDialog extends Dialog {
m_bindingContext
=
initDataBindings
();
}
private
void
renderAdvancedSection
(
TabFolder
tabFolder
)
{
InstCodeSettings
instCodeSettings
=
settings
.
getInstCodeSettings
();
TabItem
advancedTab
=
new
TabItem
(
tabFolder
,
SWT
.
NONE
);
advancedTab
.
setText
(
"Advanced"
);
ScrolledComposite
tabContents
=
new
ScrolledComposite
(
tabFolder
,
SWT
.
V_SCROLL
);
tabContents
.
setExpandHorizontal
(
true
);
tabContents
.
setShowFocusedControl
(
true
);
advancedTab
.
setControl
(
tabContents
);
Composite
composite
=
new
Composite
(
tabContents
,
SWT
.
NONE
);
composite
.
setLayout
(
new
GridLayout
(
1
,
false
));
composite
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
2
,
1
));
renderAdvancedControllSection
(
composite
);
Group
instCodesGroup
=
new
Group
(
composite
,
SWT
.
BORDER
);
instCodesGroup
.
setLayout
(
new
GridLayout
());
instCodesGroup
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
FILL
,
true
,
true
));
instCodesGroup
.
setText
(
"Selected institute codes"
);
grpInstCodes
=
new
Composite
(
instCodesGroup
,
SWT
.
FILL
);
grpInstCodes
.
setLayout
(
new
GridLayout
(
6
,
true
));
grpInstCodes
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
true
));
renderInstCodesList
(
composite
);
composite
.
pack
();
tabContents
.
setContent
(
composite
);
tabContents
.
setMinSize
(
composite
.
computeSize
(
SWT
.
FILL
,
SWT
.
FILL
));
}
private
void
renderAdvancedControllSection
(
Composite
composite
)
{
InstCodeSettings
instCodeSettings
=
settings
.
getInstCodeSettings
();
Group
controlSection
=
new
Group
(
composite
,
SWT
.
BORDER
);
controlSection
.
setLayout
(
new
GridLayout
(
1
,
false
));
controlSection
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
,
1
,
1
));
controlSection
.
setText
(
"Institute codes filtering"
);
Composite
radioButtonsComposite
=
new
Composite
(
controlSection
,
SWT
.
NONE
);
radioButtonsComposite
.
setLayout
(
new
GridLayout
(
2
,
false
));
Button
isWhitelistButton
=
new
Button
(
radioButtonsComposite
,
SWT
.
RADIO
);
isWhitelistButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
instCodeSettings
.
setBlackList
(
false
);
}
});
isWhitelistButton
.
setSelection
(!
instCodeSettings
.
isBlackList
());
isWhitelistButton
.
setText
(
"Whitelist"
);
Button
isBlacklitButton
=
new
Button
(
radioButtonsComposite
,
SWT
.
RADIO
);
isBlacklitButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
instCodeSettings
.
setBlackList
(
true
);
}
});
isBlacklitButton
.
setSelection
(
instCodeSettings
.
isBlackList
());
isBlacklitButton
.
setText
(
"Blacklist"
);
Button
saveBtn
=
new
Button
(
composite
,
SWT
.
NONE
);
saveBtn
.
setLayoutData
(
new
GridData
(
SWT
.
END
,
SWT
.
CENTER
,
false
,
false
));
saveBtn
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
event
)
{
try
{
settings
.
save
(
workspacePath
+
"/local.properties"
);
}
catch
(
IOException
err
)
{
System
.
err
.
println
(
"Failed to load props: "
+
err
.
getMessage
());
}
}
});
saveBtn
.
setText
(
"Save"
);
txtInstCodesToIgnore
=
new
Text
(
controlSection
,
SWT
.
BORDER
);
txtInstCodesToIgnore
.
setLayoutData
(
new
GridData
(
SWT
.
FILL
,
SWT
.
CENTER
,
true
,
false
));
txtInstCodesToIgnore
.
setTextLimit
(
6
);
txtInstCodesToIgnore
.
addListener
(
SWT
.
FocusOut
,
new
Listener
()
{
@Override
public
void
handleEvent
(
Event
event
)
{
if
(!
txtInstCodesToIgnore
.
getText
().
trim
().
isEmpty
())
{
instCodeSettings
.
getInstCodes
().
add
(
txtInstCodesToIgnore
.
getText
().
trim
());
txtInstCodesToIgnore
.
setText
(
""
);
renderInstCodesList
(
composite
);
}
}
});
txtInstCodesToIgnore
.
addKeyListener
(
new
KeyAdapter
()
{
@Override
public
void
keyReleased
(
KeyEvent
e
)
{
final
int
ENTER_KEY_CODE
=
13
;
if
(
e
.
keyCode
==
ENTER_KEY_CODE
&&
!
txtInstCodesToIgnore
.
getText
().
trim
().
isEmpty
())
{
instCodeSettings
.
getInstCodes
().
add
(
txtInstCodesToIgnore
.
getText
().
trim
());
txtInstCodesToIgnore
.
setText
(
""
);
renderInstCodesList
(
composite
);
}
}
});
}
private
void
renderInstCodesList
(
Composite
parent
)
{
InstCodeSettings
instCodeSettings
=
settings
.
getInstCodeSettings
();
Set
<
String
>
instCodes
=
instCodeSettings
.
getInstCodes
();
if
(
grpInstCodes
!=
null
)
{
for
(
Control
control
:
grpInstCodes
.
getChildren
())
{
control
.
dispose
();
}
}
for
(
String
instCode
:
instCodes
)
{
Group
someGroup
=
new
Group
(
grpInstCodes
,
SWT
.
FILL
);
someGroup
.
setLayout
(
new
GridLayout
(
2
,
false
));
someGroup
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
Label
lblGenesysServer
=
new
Label
(
someGroup
,
SWT
.
NONE
);
lblGenesysServer
.
setLayoutData
(
new
GridData
(
SWT
.
BEGINNING
,
SWT
.
CENTER
,
true
,
false
));
lblGenesysServer
.
setText
(
instCode
);
Button
removeInstCodeButton
=
new
Button
(
someGroup
,
SWT
.
PUSH
);
removeInstCodeButton
.
setData
(
instCode
);
removeInstCodeButton
.
setLayoutData
(
new
GridData
(
SWT
.
END
,
SWT
.
CENTER
,
true
,
true
));
removeInstCodeButton
.
addSelectionListener
(
new
SelectionAdapter
()
{
@Override
public
void
widgetSelected
(
SelectionEvent
e
)
{
instCodes
.
remove
(
instCode
);
renderInstCodesList
(
parent
);
}
});
removeInstCodeButton
.
setData
(
instCode
);
removeInstCodeButton
.
setText
(
"X"
);
}
grpInstCodes
.
pack
();
parent
.
pack
();
shell
.
layout
(
true
,
true
);
}
private
void
renderServerSection
(
Group
grpGenesysServer
,
Group
grpGenesysApiConfiguration
)
{
OAuthSettings
oauthSettings
=
settings
.
getOauthSettings
();
...
...
anno-gui/src/main/java/org/genesys2/anno/model/InstCodeSettings.java
0 → 100644
View file @
6c8ce659
package
org.genesys2.anno.model
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.util.Arrays
;
import
java.util.Properties
;
import
java.util.Set
;
import
java.util.TreeSet
;
public
class
InstCodeSettings
extends
LoadableSettings
{
private
static
String
instCodesPropName
=
"instCodes"
;
private
static
String
isBlackListPropName
=
"isBlackList"
;
private
Set
<
String
>
instCodes
=
new
TreeSet
<>();
private
boolean
isBlackList
=
false
;
public
Set
<
String
>
getInstCodes
()
{
return
instCodes
;
}
public
void
setInstCodes
(
Set
<
String
>
instCodes
)
{
firePropertyChange
(
"instCodes"
,
null
,
this
.
instCodes
);
this
.
instCodes
=
instCodes
;
}
public
boolean
isBlackList
()
{
return
isBlackList
;
}
public
void
setBlackList
(
boolean
blackList
)
{
firePropertyChange
(
"isBlackList"
,
null
,
this
.
isBlackList
);
isBlackList
=
blackList
;
}
@Override
public
void
save
(
String
propFilePath
)
throws
IOException
{
firePropertyChange
(
"instCodeSettings"
,
null
,
this
);
Properties
prop
=
new
Properties
();
prop
.
setProperty
(
instCodesPropName
,
this
.
getInstCodes
().
toString
());
prop
.
setProperty
(
isBlackListPropName
,
String
.
valueOf
(
this
.
isBlackList
()));
prop
.
store
(
new
FileOutputStream
(
propFilePath
),
"Inst codes filtering saved"
);
}
@Override
public
LoadableSettings
load
(
String
propFilePath
)
throws
IOException
{
Properties
prop
=
new
Properties
();
prop
.
load
(
new
FileInputStream
(
propFilePath
));
if
(!
prop
.
isEmpty
())
{
this
.
instCodes
=
new
TreeSet
<>(
Arrays
.
asList
(
prop
.
getProperty
(
instCodesPropName
).
replaceAll
(
"[,\\[\\]]"
,
""
).
split
(
" +"
)));
this
.
isBlackList
=
Boolean
.
valueOf
(
prop
.
getProperty
(
isBlackListPropName
));
}
firePropertyChange
(
"instCodeSettings"
,
null
,
this
);
return
this
;
}
}
anno-gui/src/main/java/org/genesys2/anno/model/LoadableSettings.java
0 → 100644
View file @
6c8ce659
package
org.genesys2.anno.model
;
import
org.genesys2.anno.gui.AbstractModelObject
;
import
java.io.IOException
;
public
abstract
class
LoadableSettings
extends
AbstractModelObject
{
public
abstract
void
save
(
String
propFilePath
)
throws
IOException
;
public
abstract
LoadableSettings
load
(
String
propFilePath
)
throws
IOException
;
}
anno-gui/src/main/java/org/genesys2/anno/model/Settings.java
View file @
6c8ce659
...
...
@@ -15,10 +15,12 @@
*/
package
org.genesys2.anno.model
;
import
org.genesys2.anno.gui.AbstractModelObject
;
import
java.io.IOException
;
public
class
Settings
extends
LoadableSettings
{
public
class
Settings
extends
AbstractModelObject
{
private
OAuthSettings
oauthSettings
=
new
OAuthSettings
();
private
InstCodeSettings
instCodeSettings
=
new
InstCodeSettings
();
public
OAuthSettings
getOauthSettings
()
{
return
oauthSettings
;
...
...
@@ -28,4 +30,25 @@ public class Settings extends AbstractModelObject {
this
.
oauthSettings
=
oauthSettings
;
firePropertyChange
(
"oauthSettings"
,
null
,
this
.
oauthSettings
);
}
public
InstCodeSettings
getInstCodeSettings
()
{
return
instCodeSettings
;
}
public
void
setInstCodeSettings
(
InstCodeSettings
instCodeSettings
)
{
firePropertyChange
(
"instCodeSettings"
,
null
,
this
.
instCodeSettings
);
this
.
instCodeSettings
=
instCodeSettings
;
}
@Override
public
void
save
(
String
propFilePath
)
throws
IOException
{
instCodeSettings
.
save
(
propFilePath
);
}
@Override
public
LoadableSettings
load
(
String
propFilePath
)
throws
IOException
{
setInstCodeSettings
((
InstCodeSettings
)
instCodeSettings
.
load
(
propFilePath
));
return
this
;
}
}
Write
Preview
Markdown
is supported
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