Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Philipp Spohr
YoshikoWrapper
Commits
b784a509
Commit
b784a509
authored
Dec 11, 2017
by
Philipp Spohr
Browse files
Retrieving of solutions associated with a result via CyRest
parent
8348de18
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java
View file @
b784a509
...
...
@@ -113,12 +113,19 @@ public class CyActivator extends AbstractCyActivator {
}
//Register commands / CyRest
TaskFactory
commandTaskFactory
=
new
CommandTaskFactory
(
YoshikoCommand
.
PERFORM_ALGORITHM
);
Properties
props
=
new
Properties
();
props
.
setProperty
(
COMMAND_NAMESPACE
,
"yoshiko"
);
props
.
setProperty
(
COMMAND
,
YoshikoCommand
.
PERFORM_ALGORITHM
.
toString
());
props
.
setProperty
(
COMMAND_DESCRIPTION
,
"Cluster a network with the Yoshiko algorithm"
);
registerService
(
context
,
commandTaskFactory
,
TaskFactory
.
class
,
props
);
TaskFactory
commandTaskFactory_PERFORM_ALGORITHM
=
new
CommandTaskFactory
(
YoshikoCommand
.
PERFORM_ALGORITHM
);
Properties
props_PERFORM_ALGORITHM
=
new
Properties
();
props_PERFORM_ALGORITHM
.
setProperty
(
COMMAND_NAMESPACE
,
"yoshiko"
);
props_PERFORM_ALGORITHM
.
setProperty
(
COMMAND
,
YoshikoCommand
.
PERFORM_ALGORITHM
.
toString
());
props_PERFORM_ALGORITHM
.
setProperty
(
COMMAND_DESCRIPTION
,
"Cluster a network with the Yoshiko algorithm"
);
registerService
(
context
,
commandTaskFactory_PERFORM_ALGORITHM
,
TaskFactory
.
class
,
props_PERFORM_ALGORITHM
);
TaskFactory
commandTaskFactory_GET_SOLUTIONS
=
new
CommandTaskFactory
(
YoshikoCommand
.
GET_SOLUTIONS
);
Properties
props_GET_SOLUTIONS
=
new
Properties
();
props_GET_SOLUTIONS
.
setProperty
(
COMMAND_NAMESPACE
,
"yoshiko"
);
props_GET_SOLUTIONS
.
setProperty
(
COMMAND
,
YoshikoCommand
.
GET_SOLUTIONS
.
toString
());
props_GET_SOLUTIONS
.
setProperty
(
COMMAND_DESCRIPTION
,
"Retrieve solutions associated with a result"
);
registerService
(
context
,
commandTaskFactory_GET_SOLUTIONS
,
TaskFactory
.
class
,
props_GET_SOLUTIONS
);
//Initialize and register main panel
MainPanel
mainPanel
=
new
MainPanel
();
...
...
src/main/java/de/hhu/ba/yoshikoWrapper/core/ResultList.java
View file @
b784a509
...
...
@@ -4,6 +4,11 @@ import java.util.HashMap;
import
de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult
;
/**
* Simple wrapper for a HashMap that manages unique IDs
* @author Philipp Spohr, Dec 11, 2017
*
*/
public
class
ResultList
{
private
static
HashMap
<
Integer
,
YoshikoResult
>
map
=
new
HashMap
<
Integer
,
YoshikoResult
>();
...
...
@@ -24,5 +29,12 @@ public class ResultList {
map
.
remove
(
resultID
);
}
public
static
YoshikoResult
get
(
int
resultID
)
{
if
(
map
.
containsKey
(
resultID
))
{
return
map
.
get
(
resultID
);
}
return
null
;
}
}
src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/CommandTaskFactory.java
View file @
b784a509
...
...
@@ -6,6 +6,7 @@ import org.cytoscape.work.TaskIterator;
import
de.hhu.ba.yoshikoWrapper.core.ParameterSet
;
import
de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask
;
import
de.hhu.ba.yoshikoWrapper.tasks.CreateClusterViewsTask
;
import
de.hhu.ba.yoshikoWrapper.tasks.GetSolutionsTask
;
public
class
CommandTaskFactory
implements
TaskFactory
{
...
...
@@ -32,6 +33,13 @@ public class CommandTaskFactory implements TaskFactory{
else
if
(
command
==
YoshikoCommand
.
CREATE_META_GRAPH
)
{
return
null
;
}
else
if
(
command
==
YoshikoCommand
.
GET_SOLUTIONS
)
{
return
new
TaskIterator
(
new
GetSolutionsTask
()
);
}
else
if
(
command
==
YoshikoCommand
.
PERFORM_ALGORITHM
)
{
return
new
TaskIterator
(
new
AlgorithmTask
(
...
...
src/main/java/de/hhu/ba/yoshikoWrapper/taskFactories/YoshikoCommand.java
View file @
b784a509
...
...
@@ -11,7 +11,8 @@ public enum YoshikoCommand {
*/
CREATE_CLUSTER_VIEW
,
CREATE_META_GRAPH
,
PERFORM_ALGORITHM
;
PERFORM_ALGORITHM
,
GET_SOLUTIONS
;
@Override
public
String
toString
()
{
...
...
@@ -21,6 +22,9 @@ public enum YoshikoCommand {
else
if
(
this
==
CREATE_CLUSTER_VIEW
)
{
return
"createcvs"
;
}
else
if
(
this
==
GET_SOLUTIONS
)
{
return
"solutions"
;
}
return
"null"
;
}
}
...
...
src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java
View file @
b784a509
...
...
@@ -292,7 +292,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
public
<
R
>
R
getResults
(
Class
<?
extends
R
>
type
)
{
//We return the id of the result so we can work with the result from CMD
if
(
type
.
equals
(
String
.
class
))
{
return
(
R
)
(
""
+
result
.
getID
());
return
(
R
)
(
"
Result generated with ID:
"
+
result
.
getID
());
}
return
null
;
}
...
...
src/main/java/de/hhu/ba/yoshikoWrapper/tasks/GetSolutionsTask.java
0 → 100644
View file @
b784a509
package
de.hhu.ba.yoshikoWrapper.tasks
;
import
java.util.ArrayList
;
import
org.cytoscape.work.ObservableTask
;
import
org.cytoscape.work.TaskMonitor
;
import
org.cytoscape.work.Tunable
;
import
de.hhu.ba.yoshikoWrapper.core.ResultList
;
import
de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult
;
import
de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution
;
public
class
GetSolutionsTask
implements
ObservableTask
{
@Tunable
(
description
=
"The result ID for which the solutions should be displayed"
,
context
=
"nogui"
)
public
int
resultID
=
-
1
;
private
ArrayList
<
YoshikoSolution
>
solutions
;
@Override
public
void
run
(
TaskMonitor
taskMonitor
)
throws
Exception
{
YoshikoResult
result
=
ResultList
.
get
(
resultID
);
if
(
result
==
null
)
{
throw
new
Exception
(
"No result with ID: "
+
resultID
+
" was found!"
);
//TODO: Localization
}
solutions
=
result
.
getSolutions
();
}
@Override
public
void
cancel
()
{
// TODO Auto-generated method stub
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
<
R
>
R
getResults
(
Class
<?
extends
R
>
type
)
{
if
(
type
.
equals
(
String
.
class
))
{
String
ret
=
""
;
for
(
YoshikoSolution
s:
solutions
)
{
ret
+=
"Solution ["
+
s
.
getId
()+
"]: "
+
s
.
getClusters
().
size
()+
" clusters\n"
;
}
return
(
R
)
ret
;
}
return
null
;
}
}
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