3700 |
07 May 10 |
fredrik |
1 |
package satoshi; |
3700 |
07 May 10 |
fredrik |
2 |
|
3700 |
07 May 10 |
fredrik |
3 |
import org.proteios.action.ProteiosAction; |
3700 |
07 May 10 |
fredrik |
4 |
import org.proteios.action.job.ListJobs; |
3700 |
07 May 10 |
fredrik |
5 |
import org.proteios.core.BooleanParameterType; |
3700 |
07 May 10 |
fredrik |
6 |
import org.proteios.core.DbControl; |
3700 |
07 May 10 |
fredrik |
7 |
import org.proteios.core.Directory; |
3700 |
07 May 10 |
fredrik |
8 |
import org.proteios.core.FloatParameterType; |
3700 |
07 May 10 |
fredrik |
9 |
import org.proteios.core.ItemFactory; |
3700 |
07 May 10 |
fredrik |
10 |
import org.proteios.core.ItemParameterType; |
3700 |
07 May 10 |
fredrik |
11 |
import org.proteios.core.Job; |
3700 |
07 May 10 |
fredrik |
12 |
import org.proteios.core.PluginDefinition; |
3700 |
07 May 10 |
fredrik |
13 |
import org.proteios.core.Project; |
3700 |
07 May 10 |
fredrik |
14 |
import org.proteios.core.StringParameterType; |
3700 |
07 May 10 |
fredrik |
15 |
|
3700 |
07 May 10 |
fredrik |
16 |
import se.lu.thep.waf.ActionException; |
3700 |
07 May 10 |
fredrik |
17 |
import se.lu.thep.waf.constraints.InvalidParameterValue; |
3700 |
07 May 10 |
fredrik |
18 |
|
3700 |
07 May 10 |
fredrik |
19 |
/** |
3700 |
07 May 10 |
fredrik |
* Creates an export job for each file id |
3700 |
07 May 10 |
fredrik |
21 |
* |
3702 |
10 May 10 |
fredrik |
* @author satoshi |
3700 |
07 May 10 |
fredrik |
23 |
*/ |
3700 |
07 May 10 |
fredrik |
24 |
public class CreateLibraryExportJob |
3700 |
07 May 10 |
fredrik |
25 |
extends ProteiosAction<CreateLibraryExportJob> |
3700 |
07 May 10 |
fredrik |
26 |
{ |
3700 |
07 May 10 |
fredrik |
27 |
@Override |
3700 |
07 May 10 |
fredrik |
28 |
protected void runMe() |
3700 |
07 May 10 |
fredrik |
29 |
throws ActionException, InvalidParameterValue |
3700 |
07 May 10 |
fredrik |
30 |
{ |
3700 |
07 May 10 |
fredrik |
31 |
/* |
3700 |
07 May 10 |
fredrik |
* Get a valid list of file ids |
3700 |
07 May 10 |
fredrik |
33 |
*/ |
3700 |
07 May 10 |
fredrik |
// List<Integer> files = getValidIntegerList(FormFactory.VID); |
3700 |
07 May 10 |
fredrik |
35 |
Float fdr = getValidFloat(LibraryExportForm.FDRCUTOFF); |
4545 |
26 Feb 14 |
fredrik |
36 |
Float fragTol = getValidFloat(LibraryExportForm.FRAGMENTTOL); |
3700 |
07 May 10 |
fredrik |
37 |
String prefix2 = getValidString(LibraryExportForm.OUTFILENAME); |
3700 |
07 May 10 |
fredrik |
38 |
String prefix3 = getValidString(LibraryExportForm.OUTFILENAME2); |
4264 |
26 Oct 11 |
fredrik |
39 |
Boolean ssl = getValidBoolean(LibraryExportForm.SSLFORMAT); |
3700 |
07 May 10 |
fredrik |
40 |
Boolean msp = getValidBoolean(LibraryExportForm.MSPFORMAT); |
4545 |
26 Feb 14 |
fredrik |
41 |
Boolean eValue = getValidBoolean(LibraryExportForm.EVALUE); |
4545 |
26 Feb 14 |
fredrik |
42 |
if (eValue == null) |
4545 |
26 Feb 14 |
fredrik |
43 |
eValue = new Boolean(false); |
4264 |
26 Oct 11 |
fredrik |
44 |
if (ssl == null) |
4264 |
26 Oct 11 |
fredrik |
45 |
ssl = new Boolean(false); |
4264 |
26 Oct 11 |
fredrik |
46 |
if (msp == null) |
4264 |
26 Oct 11 |
fredrik |
47 |
msp = new Boolean(false); |
4545 |
26 Feb 14 |
fredrik |
48 |
if (!msp.booleanValue() && !ssl.booleanValue()){ |
4545 |
26 Feb 14 |
fredrik |
49 |
throw new ActionException( |
4545 |
26 Feb 14 |
fredrik |
50 |
"Failed to initialize job. Missing output format"); |
3700 |
07 May 10 |
fredrik |
51 |
} |
4264 |
26 Oct 11 |
fredrik |
52 |
|
3700 |
07 May 10 |
fredrik |
53 |
/* |
3700 |
07 May 10 |
fredrik |
* Get the plugin to execute by getting its PluginDefinition. This time |
3700 |
07 May 10 |
fredrik |
* get the class name of the plugin of interest Make sure the plugin is |
3700 |
07 May 10 |
fredrik |
* installed first. |
3700 |
07 May 10 |
fredrik |
57 |
*/ |
3700 |
07 May 10 |
fredrik |
58 |
DbControl dc = newDbControl(); |
3700 |
07 May 10 |
fredrik |
59 |
PluginDefinition plugin = PluginDefinition.getByClassName(dc, |
3700 |
07 May 10 |
fredrik |
60 |
LibraryExportPlugin.class.getName()); |
3700 |
07 May 10 |
fredrik |
61 |
/* |
3700 |
07 May 10 |
fredrik |
* Get the files |
3700 |
07 May 10 |
fredrik |
63 |
*/ |
3700 |
07 May 10 |
fredrik |
64 |
ItemFactory factory = new ItemFactory(dc); |
3700 |
07 May 10 |
fredrik |
// for (Integer fileId : files) |
3700 |
07 May 10 |
fredrik |
66 |
// { |
3700 |
07 May 10 |
fredrik |
67 |
Job job = factory.createJob(plugin, null); |
3700 |
07 May 10 |
fredrik |
68 |
job.setName(plugin.getName()); // pass the name of the plugin |
3700 |
07 May 10 |
fredrik |
69 |
FloatParameterType prefixParam = new FloatParameterType(); |
4264 |
26 Oct 11 |
fredrik |
70 |
job.setParameterValue(LibraryExportPlugin.FDRCUTOFFPARAM, prefixParam, |
4264 |
26 Oct 11 |
fredrik |
71 |
fdr); |
4545 |
26 Feb 14 |
fredrik |
72 |
job.setParameterValue(LibraryExportPlugin.FRAGMENTTOLERANCEPARAM, new FloatParameterType(), |
4545 |
26 Feb 14 |
fredrik |
73 |
fragTol); |
3700 |
07 May 10 |
fredrik |
74 |
StringParameterType prefixParam2 = new StringParameterType(); |
4264 |
26 Oct 11 |
fredrik |
75 |
job.setParameterValue(LibraryExportPlugin.OUTFILEPARAM, prefixParam2, |
4264 |
26 Oct 11 |
fredrik |
76 |
prefix2); |
3700 |
07 May 10 |
fredrik |
77 |
StringParameterType prefixParam3 = new StringParameterType(); |
4264 |
26 Oct 11 |
fredrik |
78 |
job.setParameterValue(LibraryExportPlugin.OUTFILEPARAM2, prefixParam3, |
4264 |
26 Oct 11 |
fredrik |
79 |
prefix3); |
3700 |
07 May 10 |
fredrik |
80 |
BooleanParameterType prefixParam4 = new BooleanParameterType(); |
4264 |
26 Oct 11 |
fredrik |
81 |
job.setParameterValue(LibraryExportPlugin.SSLPARAM, prefixParam4, ssl); |
3700 |
07 May 10 |
fredrik |
82 |
BooleanParameterType prefixParam5 = new BooleanParameterType(); |
3700 |
07 May 10 |
fredrik |
83 |
job.setParameterValue(LibraryExportPlugin.MSPPARAM, prefixParam5, msp); |
4545 |
26 Feb 14 |
fredrik |
84 |
job.setParameterValue(LibraryExportPlugin.EVALUEPARAM, new BooleanParameterType(), eValue); |
3700 |
07 May 10 |
fredrik |
85 |
Project project = isProjectActive(dc); // returns the active project if |
4264 |
26 Oct 11 |
fredrik |
// any |
4264 |
26 Oct 11 |
fredrik |
87 |
Directory dir = project.getProjectDirectory(); // returns the project |
4264 |
26 Oct 11 |
fredrik |
// directory path |
4545 |
26 Feb 14 |
fredrik |
89 |
job.setDescription("Library export "+ project.getName()); |
3700 |
07 May 10 |
fredrik |
90 |
ItemParameterType<Directory> dirParam = new ItemParameterType<Directory>( |
3700 |
07 May 10 |
fredrik |
91 |
Directory.class, null); |
3700 |
07 May 10 |
fredrik |
92 |
job.setParameterValue("directory", dirParam, dir); |
3700 |
07 May 10 |
fredrik |
93 |
ItemParameterType<Project> projectParam = new ItemParameterType<Project>( |
3700 |
07 May 10 |
fredrik |
94 |
Project.class, null); |
3700 |
07 May 10 |
fredrik |
95 |
job.setParameterValue("project", projectParam, project); |
3700 |
07 May 10 |
fredrik |
96 |
// |
3700 |
07 May 10 |
fredrik |
97 |
dc.saveItem(job); |
3700 |
07 May 10 |
fredrik |
// jobCount++; |
3700 |
07 May 10 |
fredrik |
99 |
dc.commit(); |
3700 |
07 May 10 |
fredrik |
100 |
setMessage("job created"); |
3700 |
07 May 10 |
fredrik |
101 |
setForwardTo(ListJobs.class); |
3700 |
07 May 10 |
fredrik |
102 |
} |
3700 |
07 May 10 |
fredrik |
103 |
} |