示例#1
0
  /**
   * Retrieves the identifying number of the relation definition that is 'allowed' between two
   * specified node types. The results are dependent on there being only one type of relation
   * between two node types (not enforced, thus unpredictable). Makes use of a typeRelNodes.
   *
   * @param snum The first objectnode type (the source)
   * @param dnum The second objectnode type (the destination)
   * @return the number of the found relation, or -1 if either no relation was found, or more than
   *     one was found.
   */
  public int getAllowedRelationType(int snum, int dnum) {
    Set<MMObjectNode> set =
        new HashSet<MMObjectNode>(typeRelNodes.getBySourceDestination(snum, dnum));
    set.addAll(inverseTypeRelNodes.getByDestinationSource(dnum, snum));

    if (set.size() != 1) {
      return -1;
    } else {
      MMObjectNode n = set.iterator().next();
      return n.getIntValue("rnumber");
    }
  }
示例#2
0
 /**
  * A Set of all allowed relations of a certain role between two builders. Distinction is made
  * between source and destination depending on passed directionality.
  *
  * @since MMBase-1.6.2
  */
 public Set<MMObjectNode> getAllowedRelations(
     int builder1, int builder2, int role, int directionality) {
   Set<MMObjectNode> res = new HashSet<MMObjectNode>();
   if (directionality != RelationStep.DIRECTIONS_SOURCE) {
     res.addAll(typeRelNodes.getBySourceDestinationRole(builder1, builder2, role));
   }
   if (directionality != RelationStep.DIRECTIONS_DESTINATION
       && (directionality != RelationStep.DIRECTIONS_EITHER || res.isEmpty())) {
     res.addAll(inverseTypeRelNodes.getByDestinationSourceRole(builder2, builder1, role));
   }
   return res;
 }
示例#3
0
 JdbcIndexDefinition(
     DataSource ds,
     Element element,
     Set allIndexedFields,
     boolean storeText,
     boolean mergeText,
     Analyzer a,
     boolean isSub) {
   this.dataSource = ds;
   indexSql = element.getAttribute("sql");
   key = element.getAttribute("key");
   String elementId = element.getAttribute("identifier");
   identifier = "".equals(elementId) ? key : elementId;
   findSql = element.getAttribute("find");
   NodeList childNodes = element.getChildNodes();
   for (int k = 0; k < childNodes.getLength(); k++) {
     if (childNodes.item(k) instanceof Element) {
       Element childElement = (Element) childNodes.item(k);
       if ("field".equals(childElement.getLocalName())) {
         if (childElement.getAttribute("keyword").equals("true")) {
           keyWords.add(childElement.getAttribute("name"));
         }
         String m = childElement.getAttribute("multiple");
         if ("".equals(m)) m = "add";
         if (!m.equals("add")) {
           nonDefaultMultiples.put(
               childElement.getAttribute("name"), Indexer.Multiple.valueOf(m.toUpperCase()));
         }
         String b = childElement.getAttribute("boost");
         if (!b.equals("")) {
           boosts.put(childElement.getAttribute("name"), Float.valueOf(b));
         }
       } else if ("related".equals(childElement.getLocalName())) {
         subQueries.add(
             new JdbcIndexDefinition(
                 ds, childElement, allIndexedFields, storeText, mergeText, a, true));
       }
     }
   }
   this.analyzer = a;
   this.isSub = isSub;
   assert !isSub || "".equals(findSql);
 }
示例#4
0
 public Set<String> getIdentifiers() {
   Set<String> ids = new HashSet<String>();
   ids.add(getIdentifier());
   return ids;
 }