Changeset 7494
- Timestamp:
- Jun 4, 2018, 8:42:46 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/3.12-stable merged: 7477,7481-7491 /tags/3.12.3 (added) merged: 7492
- Property svn:mergeinfo changed
-
trunk/config/dist/base.config
r7414 r7494 267 267 # =================== 268 268 269 # URL to a 'freegeoip' server. Use {IP} as a placeholder for 270 # the IP address. The service should return a JSON data object. 271 # Software for running your own server can be downloaded from 272 # https://github.com/fiorix/freegeoip 273 # If no service is specified, location lookup will be disabled 274 geolocation.freegeoip = http://freegeoip.net/json/{IP} 269 # URL to the 'ipstack' (previously 'freegeoip') server. Use {IP} as a 270 # placeholder for the IP address. The service should return a JSON 271 # data object. Before it can be used you need to register and receive 272 # an API key. See https://ipstack.com/ for more information. 273 # Replace [API_KEY] in the URL below and uncomment the setting to 274 # activate geolocation lookup. 275 # geolocation.freegeoip = http://api.ipstack.com/{IP}?access_key=[API_KEY]&output=json 275 276 276 277 # A template URL for displaying a map with a marker on a specified location -
trunk/src/core/net/sf/basedb/core/AnnotationSimpleRestriction.java
r7461 r7494 113 113 114 114 /** 115 Creates a new annotation restriction for a specific <code>valueType</code>. 116 The restriction is with a list of values. 117 118 @param alias The alias of a joined item where the annotations are 119 located or null to use the root entity of the query 120 @param annotationType The annotation type to use in the query 121 @param operator The operator, it must be one of the expression 122 operators, EQ, NEQ, etc., not a boolean operator, AND, OR, etc. 123 @param values The list of values that should be used in the query, they must be of the 124 correct value type for the annotation as defined by the 125 {@link AnnotationType#getValueType()} property. 126 @param options Options that specify which annotations to consider when searching 127 @throws InvalidDataException If any of the parameters are null 128 or not follow the rules above 129 @since 3.12.3 130 */ 131 public AnnotationSimpleRestriction(String alias, AnnotationType annotationType, Operator operator, List<Object> values, 132 Options options) 133 throws InvalidDataException 134 { 135 super(alias, annotationType, options); 136 if (operator == null) throw new InvalidUseOfNullException("operator"); 137 if (values == null) throw new InvalidUseOfNullException("values"); 138 if (!operator.isExpressionOperator()) 139 { 140 throw new InvalidDataException("Invalid operator for expression: "+operator); 141 } 142 for (Object obj : values) 143 { 144 if (obj != null && !valueType.isCorrectType(obj) && !(valueType.isNumerical() && obj instanceof Number)) 145 { 146 throw new InvalidDataException("Value '"+obj+"' is a "+ 147 obj.getClass()+", not a "+valueType); 148 } 149 } 150 this.operator = operator; 151 this.value = null; 152 this.values = values; 153 } 154 155 156 /** 115 157 @since 2.4 116 158 @deprecated in 3.5; Use {@link #AnnotationSimpleRestriction(String, int, Type, Operator, Object, boolean, boolean)} instead … … 163 205 /** 164 206 @since 3.5 165 @deprecated In 3.11, use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, Object, AnnotationRestriction.Options)} instead207 @deprecated In 3.11, use {@link #AnnotationSimpleRestriction(String, AnnotationType, Operator, List, AnnotationRestriction.Options)} instead 166 208 */ 167 209 @Deprecated -
trunk/src/core/net/sf/basedb/core/SessionControl.java
r7452 r7494 350 350 } 351 351 352 GeoLocation getLocation( )353 { 354 if (!locationLoaded )352 GeoLocation getLocation(AuthenticationMethod authMeth) 353 { 354 if (!locationLoaded && authMeth != null && authMeth != AuthenticationMethod.INTERNAL) 355 355 { 356 356 locationLoaded = true; … … 895 895 device.setLastUsed(now); 896 896 device.setLastRemoteId(getRemoteId()); 897 GeoLocation loc = getLocation( );897 GeoLocation loc = getLocation(authUser.getAuthenticationMethod()); 898 898 if (loc == null) loc = new GeoLocation(); // To force 'null' on the location fields 899 899 device.setLocation(loc.toString()); … … 1084 1084 sessionData.setLoginComment(comment); 1085 1085 sessionData.setRemoteId(getRemoteId()); 1086 GeoLocation loc = getLocation( );1086 GeoLocation loc = getLocation(authenticationMethod); 1087 1087 if (loc != null) 1088 1088 { -
trunk/src/core/net/sf/basedb/util/GeoLocation.java
r7415 r7494 240 240 241 241 HttpEntity entity = response.getEntity(); 242 Header contentType = entity.getContentType(); 243 if (contentType != null && !"application/json".equals(contentType.getValue())) 244 { 245 throw new RuntimeException("Unexpected content type: "+contentType.getValue()); 242 Header contentTypeHeader = entity.getContentType(); 243 String contentType = contentTypeHeader != null ? contentTypeHeader.getValue() : null; 244 if (contentType != null && !contentType.contains("application/json")) 245 { 246 throw new RuntimeException("Unexpected content type: "+contentType); 246 247 } 247 248 -
trunk/src/core/net/sf/basedb/util/formatter/PropertyFilterFormatter.java
r6841 r7494 112 112 sb.append(")"); 113 113 } 114 else if (property.equals(" itemSubtype"))115 { 116 // Special handling to display name of subtype114 else if (property.equals("bioWell.row") || property.equals("bioWell.column")) 115 { 116 WellCoordinateFormatter formatter = new WellCoordinateFormatter(property.equals("bioWell.row")); 117 117 sb.append(property).append(" ").append(operator).append(" "); 118 List<Object> s ubtypes= filter.getValuesAsObjects();119 if (s ubtypes.size() > 1) sb.append("(");120 if (s ubtypes.size() == 0) sb.append("null");118 List<Object> selected = filter.getValuesAsObjects(); 119 if (selected.size() > 1) sb.append("("); 120 if (selected.size() == 0) sb.append("null"); 121 121 String sep = ""; 122 for (Object i d : subtypes)122 for (Object index : selected) 123 123 { 124 124 sb.append(sep); 125 125 sep = ", "; 126 sb.append(nameOfItem(dc, Item.ITEMSUBTYPE, (Integer)id, true)); 127 } 128 if (subtypes.size() > 1) sb.append(")"); 126 sb.append(formatter.format((Integer)index)); 127 } 128 if (selected.size() > 1) sb.append(")"); 129 } 130 else if (property.equals("parentType")) 131 { 132 sb.append(property).append(" ").append(operator).append(" "); 133 List<Object> selected = filter.getValuesAsObjects(); 134 if (selected.size() > 1) sb.append("("); 135 if (selected.size() == 0) sb.append("null"); 136 String sep = ""; 137 for (Object index : selected) 138 { 139 sb.append(sep); 140 sep = ", "; 141 sb.append(Item.fromValue((Integer)index).toString()); 142 } 143 if (selected.size() > 1) sb.append(")"); 129 144 } 130 145 else 131 146 { 132 if (property.startsWith("&") || property.startsWith("@") || property.startsWith("!")) 133 { 134 property = property.substring(1); 135 } 136 sb.append(property).append(" ").append(operator).append(" "); 137 if (operator.isListOperator() && value != null) 138 { 139 appendListOfValues(sb, value, quote); 147 Item nameOfItemType = null; 148 if (property.equals("itemSubtype") || property.endsWith(".itemSubtype")) 149 { 150 // Special handling to display name of subtype 151 nameOfItemType = Item.ITEMSUBTYPE; 152 } 153 else if (property.equals("platform")) 154 { 155 // Special handling to display name of platform 156 nameOfItemType = Item.PLATFORM; 157 } 158 if (nameOfItemType != null) 159 { 160 sb.append(property).append(" ").append(operator).append(" "); 161 List<Object> itemIds = filter.getValuesAsObjects(); 162 if (itemIds.size() > 1) sb.append("("); 163 if (itemIds.size() == 0) sb.append("null"); 164 String sep = ""; 165 for (Object id : itemIds) 166 { 167 sb.append(sep); 168 sep = ", "; 169 sb.append(nameOfItem(dc, nameOfItemType, (Integer)id, true)); 170 } 171 if (itemIds.size() > 1) sb.append(")"); 140 172 } 141 173 else 142 174 { 143 if (filter.getValueType().isTemporal()) 144 { 145 value = dateFormatter.format((Date)Type.DATE.parseString(value)); 146 } 147 sb.append(quote).append(value).append(quote); 175 if (property.startsWith("&") || property.startsWith("@") || property.startsWith("!")) 176 { 177 property = property.substring(1); 178 } 179 sb.append(property).append(" ").append(operator).append(" "); 180 if (operator.isListOperator() && value != null) 181 { 182 appendListOfValues(sb, value, quote); 183 } 184 else 185 { 186 if (filter.getValueType().isTemporal()) 187 { 188 value = dateFormatter.format((Date)Type.DATE.parseString(value)); 189 } 190 sb.append(quote).append(value).append(quote); 191 } 148 192 } 149 193 } -
trunk/src/core/net/sf/basedb/util/overview/loader/DerivedBioAssayLoader.java
r7303 r7494 50 50 import net.sf.basedb.util.overview.OverviewUtil; 51 51 import net.sf.basedb.util.overview.Validator; 52 import net.sf.basedb.util.overview.filter.BasicItemFilter; 52 53 import net.sf.basedb.util.overview.filter.ItemTypeFilter; 53 54 import net.sf.basedb.util.overview.node.ChildNodeDirection; … … 157 158 protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node bioAssayNode) 158 159 { 159 getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, bioAssayNode); 160 Extract e = getExtract((DerivedBioAssay)bioAssayNode.getItem()); 161 if (e == null || bioAssayNode.getFirstParent(new BasicItemFilter(e)) == null) 162 { 163 // Only load the extract if it is not already a parent node 164 getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, bioAssayNode); 165 } 160 166 getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, bioAssayNode); 161 167 getNodeLoader(context, Item.FILESETMEMBER).createPropertyNode(dc, context, bioAssayNode); … … 281 287 NodeFactory<DerivedBioAssay> nf = getNodeFactory(dc, context); 282 288 Node folderNode = null; 289 // Load derived bioassays linked to the 'extract' if: 290 // they have no parent bioassay OR 291 // the parent bioassay has no parent extract OR 292 // the parent bioassay has a different parent extract 283 293 ItemQuery<DerivedBioAssay> query = DerivedBioAssay.getQuery(); 284 294 query.restrict(Restrictions.eq(Hql.property("extract"), Hql.entity(extract))); 285 295 query.join(Hql.leftJoin("parents", "parent")); 286 query.restrict(Restrictions.eq(Hql.alias("parent"), null)); 296 query.join(Hql.leftJoin("parent", "extract", "parentExtract", null, false)); 297 query.restrict( 298 Restrictions.or( 299 Restrictions.eq(Hql.alias("parent"), null), 300 Restrictions.eq(Hql.alias("parentExtract"), null), 301 Restrictions.neq(Hql.alias("parentExtract"), Hql.entity(extract)) 302 )); 303 query.setDistinct(true); // left joins may create multiple hits for items with more than one parent 287 304 context.initQuery(query, "name"); 288 305 ItemResultIterator<DerivedBioAssay> it = query.iterate(dc); -
trunk/src/core/net/sf/basedb/util/overview/loader/RawBioAssayLoader.java
r7303 r7494 47 47 import net.sf.basedb.util.overview.NodeAttribute; 48 48 import net.sf.basedb.util.overview.OverviewContext; 49 import net.sf.basedb.util.overview.filter.BasicItemFilter; 49 50 import net.sf.basedb.util.overview.filter.ItemTypeFilter; 50 51 import net.sf.basedb.util.overview.node.ChildNodeDirection; … … 169 170 protected void loadPropertyChildNodes(DbControl dc, OverviewContext context, Node rawBioAssayNode) 170 171 { 171 getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, rawBioAssayNode); 172 Extract e = getExtract((RawBioAssay)rawBioAssayNode.getItem()); 173 if (e == null || rawBioAssayNode.getFirstParent(new BasicItemFilter(e)) == null) 174 { 175 // Only load the extract if it is not already a parent node 176 getNodeLoader(context, Item.EXTRACT).createReverseNode(dc, context, rawBioAssayNode); 177 } 172 178 getNodeLoader(context, Item.ANNOTATION).createPropertyNode(dc, context, rawBioAssayNode); 173 179 getNodeLoader(context, Item.FILESETMEMBER).createPropertyNode(dc, context, rawBioAssayNode); … … 235 241 NodeFactory<RawBioAssay> nf = getNodeFactory(dc, context); 236 242 Node folderNode = null; 243 // Load raw bioassays linked to the 'extract' if: 244 // they have no parent bioassay OR 245 // the parent bioassay has no parent extract OR 246 // the parent bioassay has a different parent extract 237 247 ItemQuery<RawBioAssay> query = RawBioAssay.getQuery(); 238 248 query.restrict(Restrictions.eq(Hql.property("parentExtract"), Hql.entity(extract))); 239 query.restrict(Restrictions.eq(Hql.property("parentBioAssay"), null)); 249 query.join(Hql.leftJoin("parentBioAssay", "parent")); 250 query.join(Hql.leftJoin("parent", "extract", "parentExtract", null, false)); 251 query.restrict( 252 Restrictions.or( 253 Restrictions.eq(Hql.alias("parent"), null), 254 Restrictions.eq(Hql.alias("parentExtract"), null), 255 Restrictions.neq(Hql.alias("parentExtract"), Hql.entity(extract)) 256 )); 240 257 context.initQuery(query, "name"); 241 258 ItemResultIterator<RawBioAssay> it = query.iterate(dc); … … 253 270 } 254 271 272 /** 273 Get the extract that is associated with the current raw bioassay 274 @return The extract or null if none was found 275 */ 276 private Extract getExtract(RawBioAssay bioAssay) 277 { 278 Extract extract = null; 279 try 280 { 281 extract = bioAssay.getParentExtract(); 282 } 283 catch (PermissionDeniedException ex) 284 {} 285 return extract; 286 } 287 255 288 private Set<Integer> getExtractChain(DbControl dc, Node node) 256 289 { -
trunk/www/common/import/index.jsp
r7201 r7494 189 189 190 190 cc.setObject("auto-detected-file", f); 191 cc.setObject("last-file-charset", charset); 191 192 int matches = plugins.size(); 192 193 if (matches == 0) -
trunk/www/common/plugin/configure.jsp
r7030 r7494 99 99 } 100 100 } 101 102 // Special handling for "charset" parameter to make it match the auto-selected file 103 if (currentContext != null && Parameters.CHARSET_PARAMETER.equals(pp.getName())) 104 { 105 Object charset = currentContext.getObject("last-file-charset"); 106 if (charset != null) values = Collections.singletonList(charset); 107 } 108 101 109 // Then, we check the parameters default value 102 110 if ((values == null || values.size() == 0) && pp.getDefaultValue() != null) … … 123 131 try 124 132 { 125 values.add(File.getById(dc, cc.getId()).getPath().toString()); 133 File file = File.getById(dc, cc.getId()); 134 values.add(file.getPath().toString()); 135 if (currentContext != null && file.getCharacterSet() != null) 136 { 137 currentContext.setObject("last-file-charset", file.getCharacterSet()); 138 } 126 139 } 127 140 catch (Throwable t) -
trunk/www/common/plugin/parse_file.jsp
r6684 r7494 24 24 @version 2.0 25 25 --%> 26 <%@page import="org.json.simple.JSONObject"%>27 26 <%@ page pageEncoding="UTF-8" session="false" 28 27 contentType="text/html; charset=UTF-8" … … 49 48 import="java.io.InputStream" 50 49 import="org.json.simple.JSONArray" 50 import="org.json.simple.JSONObject" 51 51 %> 52 52 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 173 173 %> 174 174 <base:page type="iframe" title="Test with file"> 175 <base:head scripts="tabcontrol-2.js,~parse_file.js" styles="table.css,tabcontrol.css" /> 175 <base:head scripts="tabcontrol-2.js,~parse_file.js" styles="table.css,tabcontrol.css"> 176 <style> 177 #fileData td 178 { 179 white-space: nowrap; 180 max-width: 20em; 181 min-width: 4em; 182 overflow: hidden; 183 text-overflow: ellipsis; 184 } 185 #fileData td:first-child 186 { 187 font-weight: bold; 188 } 189 .skipped 190 { 191 padding: 1px 2px 1px 2px; 192 color: #777777; 193 font-style: italic; 194 } 195 </style> 196 </base:head> 176 197 <base:body> 177 198 <div class="absolutefull bottomborder"> … … 216 237 <div class="itemlist" style="<%=messages.size()==0 ? "" : "border-top-width: 1px;"%>"> 217 238 <div class="data"> 218 <table style="border: 0;" >239 <table style="border: 0;" id="fileData"> 219 240 <thead class="bg-filled-100"> 220 241 <tr> … … 234 255 int rowClassIndex = 0; 235 256 236 while (currentLine < =maxLines && currentLine < headerLines)257 while (currentLine < maxLines && currentLine < headerLines) 237 258 { 238 259 FlatFileParser.Line line = parser.getLine(currentLine); 239 260 linePatterns.add(Pattern.quote(line.line())); 240 261 String[] data = null; 262 int numMoreColumns = 0; 241 263 if (line.type() == FlatFileParser.LineType.HEADER) 242 264 { … … 246 268 { 247 269 data = parser.trimQuotes(splitter.split(line.line(), 99)); 270 if (data.length == 99) 271 { 272 numMoreColumns = splitter.split(line.line()).length - 99; 273 } 248 274 } 249 275 else … … 254 280 <tr class="<%=rowclass[rowClassIndex]%> highlight"> 255 281 <td class="cell"><%=line.lineNo()%></td> 256 <td class="cell"><%=data.length %></td>282 <td class="cell"><%=data.length+numMoreColumns%></td> 257 283 <td class="cell"><%=line.type()%></td> 258 284 <td class="cell"> … … 290 316 { 291 317 if (lastLine == FlatFileParser.LineType.DATA) parser.nextData(); 292 while (currentLine < =maxLines && parser.hasMoreData())318 while (currentLine < maxLines && parser.hasMoreData()) 293 319 { 294 320 FlatFileParser.Data data = parser.nextData(); … … 298 324 %> 299 325 <tr> 300 <td class=" error" colspan="103">326 <td class="skipped bg-filled-100" colspan="103"> 301 327 Skipped <%=parser.getNumSkippedLines()%> lines 302 328 (<%=parser.getIgnoredLines()%> ignored; <%=parser.getUnknownLines()%> unknown) … … 320 346 </td> 321 347 <% 322 for (int i = 0; i < data.columns() ; ++i)348 for (int i = 0; i < data.columns() && i < 99; ++i) 323 349 { 324 350 %> -
trunk/www/include/scripts/main-2.js
r7447 r7494 4551 4551 optionDiv.optionIndex = i; 4552 4552 optionDiv.innerHTML = options[i]; 4553 options[i].div = optionDiv;4554 4553 mainDiv.appendChild(optionDiv); 4555 4554 }
Note: See TracChangeset
for help on using the changeset viewer.