Changeset 20773
- Timestamp:
- 03/03/10 10:57:35 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bio/webapp/src/org/intermine/bio/web/logic/OrthologueConverter.java
r20767 r20773 21 21 import org.intermine.api.profile.Profile; 22 22 import org.intermine.api.query.PathQueryExecutor; 23 import org.intermine.api.query.WebResultsExecutor; 23 24 import org.intermine.api.results.ExportResultsIterator; 24 25 import org.intermine.api.results.ResultElement; … … 28 29 import org.intermine.objectstore.ObjectStoreException; 29 30 import org.intermine.pathquery.Constraints; 31 import org.intermine.pathquery.Path; 32 import org.intermine.pathquery.PathException; 30 33 import org.intermine.pathquery.PathQuery; 31 34 import org.intermine.web.logic.bag.BagConverter; 32 35 import org.intermine.web.logic.config.WebConfig; 36 import org.intermine.web.logic.pathqueryresult.PathQueryResultHelper; 33 37 34 38 /** … … 176 180 @Override 177 181 public WebResults getConvertedObjects(Profile profile, List<Integer> fromList, String type, 178 String parameters) { 179 // TODO Auto-generated method stub 180 return null; 182 String parameters) throws ObjectStoreException, PathException { 183 184 PathQuery q = new PathQuery(model); 185 List<Path> view = PathQueryResultHelper.getDefaultView(type, model, webConfig, 186 "Gene.homologues.homologue", false); 187 view = getFixedView(view); 188 q.setViewPaths(view); 189 190 List<InterMineObject> objectList = im.getObjectStore().getObjectsByIds(fromList); 191 192 // gene 193 q.addConstraint("Gene", Constraints.in(objectList)); 194 195 // organism 196 q.addConstraint("Gene.homologues.homologue.organism", Constraints.lookup(parameters)); 197 198 // homologue.type = "orthologue" 199 q.addConstraint("Gene.homologues.type", Constraints.eq("orthologue")); 200 201 q.setConstraintLogic("A and B and C"); 202 q.syncLogicExpression("and"); 203 WebResultsExecutor executor = im.getWebResultsExecutor(profile); 204 205 return executor.execute(q); 206 } 207 208 /** 209 *If view contains joined organism, this will make sure, that 210 * organism is joined as a inner join. Else constraint on organism doesn't work. 211 * @param pathQuery 212 * @param joinPath 213 * @throws PathException 214 * */ 215 private List<Path> getFixedView(List<Path> view) throws PathException { 216 String invalidPath = "Gene.homologues.homologue:organism"; 217 String validPath = "Gene.homologues.homologue.organism"; 218 List<Path> ret = new ArrayList<Path>(); 219 for (Path path : view) { 220 if (path.toString().contains(invalidPath)) { 221 String newPathString = path.toString().replace(invalidPath, validPath); 222 path = new Path(path.getModel(), newPathString); 223 } 224 ret.add(path); 225 } 226 return ret; 181 227 } 182 228 }
Note: See TracChangeset
for help on using the changeset viewer.
