Changeset 728
- Timestamp:
- Jul 17, 2008, 4:20:07 PM (15 years ago)
- Location:
- plugins/base2/net.sf.basedb.normalizations/trunk/src/net/sf/basedb
- Files:
-
- 4 added
- 3 deleted
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
plugins/base2/net.sf.basedb.normalizations/trunk/src/net/sf/basedb/plugins/AverageNormalization.java
r727 r728 24 24 */ 25 25 26 package net.sf.basedb.plugins .average;26 package net.sf.basedb.plugins; 27 27 28 28 import net.sf.basedb.core.BaseException; 29 import net.sf.basedb.core.BioAssay; 30 import net.sf.basedb.core.BioAssaySet; 31 import net.sf.basedb.core.DbControl; 32 import net.sf.basedb.core.PluginParameter; 29 33 import net.sf.basedb.core.ProgressReporter; 30 34 import net.sf.basedb.core.RequestInformation; 31 35 import net.sf.basedb.core.plugin.About; 32 36 import net.sf.basedb.core.plugin.AboutImpl; 33 import net.sf.basedb.core.plugin.AbstractPlugin;34 37 import net.sf.basedb.core.plugin.GuiContext; 35 38 import net.sf.basedb.core.plugin.InteractivePlugin; … … 37 40 import net.sf.basedb.core.plugin.Response; 38 41 import net.sf.basedb.core.signal.SignalHandler; 42 import net.sf.basedb.core.signal.SignalReceivedException; 39 43 import net.sf.basedb.core.signal.SignalTarget; 40 41 import java.util.Set; 44 import net.sf.basedb.core.signal.ThreadSignalHandler; 45 import net.sf.basedb.normalizations.Normalizations; 46 import net.sf.basedb.util.Values; 47 48 import java.util.ArrayList; 49 import java.util.Arrays; 50 import java.util.List; 42 51 43 52 /** … … 50 59 */ 51 60 public class AverageNormalization 52 extends Abstract Plugin53 implements SignalTarget, InteractivePlugin61 extends AbstractNormalizationPlugin 62 implements InteractivePlugin, SignalTarget 54 63 { 64 /** 65 Use to abort a running job 66 */ 67 private ThreadSignalHandler signalHandler; 68 69 /** 70 Holds the configured job parameters 71 */ 72 private RequestInformation configureJob = null; 73 55 74 56 75 private final About about = new AboutImpl 57 76 ( 58 77 "Average normalization plug-in", 59 "", 60 "", 61 "", 62 "", 63 "", 64 "" 78 "This normalization plug-in uses the average algorithm to adjust sample signals.\n" + 79 "\n" + 80 "This plug-in is part of the BASE 2 normalization package.", 81 Normalizations.PACKAGE_VERSION, 82 Normalizations.COPYRIGHT, 83 null, 84 Normalizations.EMAIL, 85 Normalizations.URL 65 86 ); 66 67 /* (non-Javadoc) 68 @see net.sf.basedb.core.signal.SignalTarget#getSignalHandler() 87 88 /* 89 From SignalTarget interface 90 */ 91 @Override 92 public SignalHandler getSignalHandler() 93 { 94 signalHandler = new ThreadSignalHandler(); 95 return signalHandler; 96 } 97 /* 98 --------------------------------------------------------- 99 */ 100 101 102 /* 103 From InteractivePlugin interface 69 104 */ 70 105 @Override 71 public SignalHandler getSignalHandler() 72 { 73 // TODO Auto-generated method stub 74 return null; 75 } 76 77 /* (non-Javadoc) 78 @see net.sf.basedb.core.plugin.InteractivePlugin#configure(net.sf.basedb.core.plugin.GuiContext, net.sf.basedb.core.plugin.Request, net.sf.basedb.core.plugin.Response) 79 */ 80 @Override 81 public void configure(GuiContext arg0, Request arg1, Response arg2) 82 { 83 // TODO Auto-generated method stub 84 85 } 86 87 /* (non-Javadoc) 88 @see net.sf.basedb.core.plugin.InteractivePlugin#getGuiContexts() 89 */ 90 @Override 91 public Set<GuiContext> getGuiContexts() 92 { 93 // TODO Auto-generated method stub 94 return null; 95 } 96 97 /* (non-Javadoc) 98 @see net.sf.basedb.core.plugin.InteractivePlugin#getRequestInformation(net.sf.basedb.core.plugin.GuiContext, java.lang.String) 99 */ 100 @Override 101 public RequestInformation getRequestInformation(GuiContext context, String arg1) 106 public void configure(GuiContext context, Request request, Response response) 107 { 108 String command = request.getCommand(); 109 if (command.equals(Request.COMMAND_CONFIGURE_JOB)) 110 { 111 try 112 { 113 RequestInformation ri = getConfiguredJobParameters(); 114 List<Throwable> errors = validateRequestParameters(ri.getParameters(), request); 115 if (errors != null) 116 { 117 response.setError(errors.size() + " invalid parameter(s) were found in the request", errors); 118 return; 119 } 120 121 // Source bioassay set 122 storeValue(job, request, ri.getParameter(SOURCE_BIOASSAYSET)); 123 124 // Child name, description and transformation 125 storeValue(job, request, ri.getParameter(CHILD_NAME)); 126 storeValue(job, request, ri.getParameter(CHILD_DESCRIPTION)); 127 128 //TODO Store Average Normalization specific parameters 129 } 130 catch (SignalReceivedException signalException) 131 { 132 response.setError("Aborted by user.", Arrays.asList(signalException)); 133 } 134 catch (Throwable ex) 135 { 136 response.setError(ex.getMessage(), Arrays.asList(ex)); 137 } 138 } 139 } 140 141 142 @Override 143 public RequestInformation getRequestInformation(GuiContext context, String command) 102 144 throws BaseException 103 145 { 104 // TODO Auto-generated method stub 105 return null; 106 } 107 108 /* (non-Javadoc) 109 @see net.sf.basedb.core.plugin.InteractivePlugin#isInContext(net.sf.basedb.core.plugin.GuiContext, java.lang.Object) 110 */ 111 @Override 112 public String isInContext(GuiContext arg0, Object arg1) 113 { 114 // TODO Auto-generated method stub 115 return null; 116 } 117 118 /* (non-Javadoc) 119 @see net.sf.basedb.core.plugin.Plugin#getAbout() 120 */ 146 RequestInformation requestInformation = null; 147 if (command.equals(Request.COMMAND_CONFIGURE_JOB)) 148 { 149 requestInformation = getConfiguredJobParameters(); 150 } 151 return requestInformation; 152 } 153 /* 154 --------------------------------------------------------- 155 */ 156 157 /* 158 From Plugin interface 159 */ 121 160 @Override 122 161 public About getAbout() 123 162 { 124 // TODO Auto-generated method stub 125 return null; 126 } 127 128 /* (non-Javadoc) 129 @see net.sf.basedb.core.plugin.Plugin#getMainType() 130 */ 131 @Override 132 public MainType getMainType() 133 { 134 // TODO Auto-generated method stub 135 return null; 136 } 137 138 /* (non-Javadoc) 139 @see net.sf.basedb.core.plugin.Plugin#run(net.sf.basedb.core.plugin.Request, net.sf.basedb.core.plugin.Response, net.sf.basedb.core.ProgressReporter) 140 */ 141 @Override 142 public void run(Request arg0, Response arg1, ProgressReporter arg2) 143 { 144 // TODO Auto-generated method stub 145 146 } 147 163 return about; 164 } 165 166 @Override 167 public void run(Request request, Response response, ProgressReporter progress) 168 { 169 String command = request.getCommand(); 170 if (command.equals(Request.COMMAND_EXECUTE)) 171 { 172 if (signalHandler != null) 173 { 174 signalHandler.setWorkerThread(null); 175 } 176 DbControl dc = null; 177 try 178 { 179 dc = sc.newDbControl(); 180 BioAssaySet source = getSourceBioAssaySet(dc); 181 String childName = Values.getString((String)job.getValue(CHILD_NAME), source.getName()); 182 String childDescription = (String)job.getValue(CHILD_DESCRIPTION); 183 184 List<BioAssay> referenceGroup = getReferenceGroup(dc); 185 //TODO Implement things specific for the algortihm. 186 } 187 catch (Throwable ex) 188 { 189 response.setError(ex.getMessage(), Arrays.asList(ex)); 190 } 191 finally 192 { 193 if (dc != null) dc.close(); 194 } 195 } 196 } 197 /* 198 --------------------------------------------------------- 199 */ 200 201 private RequestInformation getConfiguredJobParameters() 202 { 203 DbControl dc = null; 204 try 205 { 206 if (configureJob == null) 207 { 208 dc = sc.newDbControl(); 209 BioAssaySet bas = getCurrentBioAssaySet(dc); 210 List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>(3); 211 212 // Source and child bioassay set parameters 213 parameters.add(getSourceBioAssaySetParameter(null, null)); 214 parameters.add(getChildNameParameter(null, null, bas.getName())); 215 parameters.add(getChildDescriptionParameter(null, null, null)); 216 217 //Reference group 218 parameters.add(getReferenceGroupParameter(null, null)); 219 //TODO Configure Average Normalization specific parameters. 220 } 221 } 222 finally 223 { 224 if (dc != null ) dc.close(); 225 } 226 227 return configureJob; 228 } 148 229 }
Note: See TracChangeset
for help on using the changeset viewer.