Changeset 22655


Ignore:
Timestamp:
02/09/10 15:53:15 (17 months ago)
Author:
rns
Message:

Don't count subclass constraints when checking to see if constraint logic should be displayed.

Location:
branches/mnw21/pathquery_refactor/intermine
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/mnw21/pathquery_refactor/intermine/pathquery/main/src/org/intermine/pathquery/PathQuery.java

    r22257 r22655  
    717717     */ 
    718718    public synchronized Map<PathConstraint, String> getConstraints() { 
    719         return Collections.unmodifiableMap(new LinkedHashMap<PathConstraint, String>(constraints)); 
     719        Map<PathConstraint, String> retval = new LinkedHashMap<PathConstraint, String>(constraints); 
     720        return retval; 
    720721    } 
    721722 
     
    752753        } 
    753754        return Collections.unmodifiableList(retval); 
     755    } 
     756 
     757    /** 
     758     * Return the constraint codes used in the query, some constraint types (subclasses) don't 
     759     * get assigned a code, these are not included.  This method returns all of the codes that 
     760     * should be involved in the logic expression of the query. 
     761     * @return the constraint codes used in this query 
     762     */ 
     763    public synchronized Set<String> getConstraintCodes() { 
     764        Set<String> codes = new HashSet<String>(); 
     765        for (String code : constraints.values()) { 
     766            if (code != null) { 
     767                codes.add(code); 
     768            } 
     769        } 
     770        return codes; 
    754771    } 
    755772 
  • branches/mnw21/pathquery_refactor/intermine/pathquery/test/src/org/intermine/pathquery/PathQueryUnitTest.java

    r22397 r22655  
    873873    } 
    874874     
     875    public void testGetConstraintCodes() { 
     876        Model model = Model.getInstanceByName("testmodel"); 
     877        PathQuery q = new PathQuery(model); 
     878        q.addViews("Department.name"); 
     879        q.addConstraint(new PathConstraintSubclass("Department.employees", "Manager")); 
     880 
     881        Set<String> expected = new HashSet<String>(); 
     882        assertEquals(expected, q.getConstraintCodes()); 
     883 
     884        q.addConstraint(new PathConstraintAttribute("Department.employees.age", ConstraintOp.EQUALS, "12")); 
     885        expected.add("A"); 
     886        assertEquals(expected, q.getConstraintCodes()); 
     887 
     888        q.addConstraint(new PathConstraintAttribute("Department.name", ConstraintOp.EQUALS, "DepartmentA")); 
     889        expected.add("B"); 
     890        assertEquals(expected, q.getConstraintCodes()); 
     891    } 
     892     
    875893    public void testRemoveSubclass() throws Exception { 
    876894        Model model = Model.getInstanceByName("testmodel"); 
  • branches/mnw21/pathquery_refactor/intermine/webapp/main/resources/webapp/queryBuilderConstraintLogic.jsp

    r21872 r22655  
    2929<strong><fmt:message key="query.constraintLogic"/>:</strong> 
    3030  <c:choose> 
    31     <c:when test="${fn:length(QUERY.constraints) == 1}"> 
     31    <c:when test="${fn:length(QUERY.constraintCodes) == 1}"> 
    3232      <div class="smallnote altmessage"><fmt:message key="query.oneConstraint"/></div> 
    3333    </c:when> 
    34     <c:when test="${fn:length(QUERY.constraints) == 0}"> 
     34    <c:when test="${fn:length(QUERY.constraintCodes) == 0}"> 
    3535      <div class="smallnote altmessage"><fmt:message key="query.noConstraints"/></div> 
    3636    </c:when> 
    3737    <c:otherwise> 
    38         <span id="constraintLogic" title="Click to Edit" alt="Click to Edit">${constraintLogicExpr}</span> 
    39         <span id="editConstraintLogic" style="display: none"> 
    40             <%--<html:link action="/query?editExpression" style="font-size: 11px"> 
    41               <fmt:message key="query.logicEdit"/> 
    42             </html:link>--%> 
    43             <input type="test" name="expr" id="expr" size="20" value="${constraintLogicExpr}"/> 
    44             <button id="editconstraintlogic" type="button" style="font-size: 11px"><fmt:message key="query.logicUpdate"/></button> 
    45         </span> 
     38      <span id="constraintLogic" title="Click to Edit" alt="Click to Edit">${constraintLogicExpr}</span> 
     39      <span id="editConstraintLogic" style="display: none"> 
     40        <input type="test" name="expr" id="expr" size="20" value="${constraintLogicExpr}"/> 
     41          <button id="editconstraintlogic" type="button" style="font-size: 11px"><fmt:message key="query.logicUpdate"/></button> 
     42      </span> 
    4643    </c:otherwise> 
    4744  </c:choose> 
Note: See TracChangeset for help on using the changeset viewer.