示例#1
0
  public TreeBean() {

    String[] components = {"< a4j:ajaxListener >", "< a4j:keepAlive >", "< a4j:actionparam >"};
    String[][] attributes = {
      {"type"},
      {"ajaxOnly", "beanName"},
      {"actionListener", "assignTo", "binding", "converter", "id", "name", "noEscape", "value"}
    };

    if (data == null) {
      data = new TreeNodeImpl<String>();

      for (int i = 0; i < components.length; i++) {
        TreeNode<String> child = new TreeNodeImpl<String>();
        child.setData(components[i]);
        data.addChild(components[i], child);

        for (int j = 0; j < attributes[i].length; j++) {
          TreeNode<String> grandChild = new TreeNodeImpl<String>();
          grandChild.setData(attributes[i][j]);
          child.addChild(attributes[i][j], grandChild);
        }
      }
    }
  }
示例#2
0
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public void loadTree() {
		try {
			rootNode = new TreeNodeImpl();

			Query query = getSession().getNamedQuery("core.org.records");
			Iterator it = query.list().iterator();
			int id;
			String name, desc;
			key = 1;
			while (it.hasNext()) {
				Object obj[] = (Object[]) it.next();
				id = 0;
				name = desc = "";
				if (obj[0] != null)
					id = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[6] != null)
					name = String.valueOf(obj[6]);
				if (obj[7] != null)
					desc = String.valueOf(obj[7]);
				TreeNodeImpl nodeImpl = new TreeNodeImpl();
				nodeImpl.setData(new Department(id, 0, 0, name, name, name, desc));
				rootNode.addChild(key, nodeImpl);
				key++;
				addNodes(nodeImpl, id, 0, name, name);

			}
			it = null;

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
示例#3
0
	/*
	 * * Tree Node
	 * 
	 * @param parentCode
	 * 
	 * @param node
	 */
	@SuppressWarnings("unchecked")
	public void addNodes(TreeNode<Department> node, int orgId, int parentId, String oName, String pName) {
		try {
			Query query = getSession().getNamedQuery("core.department.getchildren");
			query.setParameter("orgId", orgId);
			query.setParameter("parentId", parentId);
			Iterator<?> it = query.list().iterator();
			int id;
			String name, desc;
			while (it.hasNext()) {
				Object obj[] = (Object[]) it.next();
				id = 0;
				name = desc = "";
				if (obj[0] != null)
					id = Integer.valueOf(String.valueOf(obj[0]));
				if (obj[1] != null)
					name = String.valueOf(obj[1]);
				if (obj[2] != null)
					desc = String.valueOf(obj[2]);
				@SuppressWarnings("rawtypes")
				TreeNodeImpl nodeImpl = new TreeNodeImpl();
				nodeImpl.setData(new Department(orgId, id, id, oName, pName, name, desc));
				node.addChild(key, nodeImpl);
				key++;
				if (hasChild(orgId, id))
					addNodes(nodeImpl, orgId, id, oName, name);
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
    public static TreeNode standardTraverseTree(
        OWLNamedClass cl, List stack, TreeNode node, boolean applyfilter) {
      Collection<RDFIndividual> instances = cl.getInstances(false);

      // adding a new category - isn't backed by any data, not even name??
      TreeNode childClass = new TreeNodeImpl();
      String instanceCountText = instances.size() > 0 ? " (" + instances.size() + ")" : "";
      childClass.setData(new DummyOntologyProperty(cl.getLocalName() + instanceCountText));
      // addChild(key, nodeImpl
      node.addChild(cl.getURI(), childClass);

      if (instances.size() > 0) {
        for (Iterator<RDFIndividual> jt = instances.iterator(); jt.hasNext(); ) {
          try {
            RDFIndividual individual = (RDFIndividual) jt.next();
            // OWLIndividual individual = (OWLIndividual) jt.next();
            TreeNode child = new TreeNodeImpl();
            OntologyProperty ontologyProperty = new OntologyPropertyImpl(individual);

            boolean bMatchesFilter = true;
            if (applyfilter) {
              boolean b1 =
                  ontologyProperty.getName().toLowerCase().contains(filterTreeString.toLowerCase());
              boolean b2 =
                  ontologyProperty
                      .getHumanReadableName()
                      .toLowerCase()
                      .contains(filterTreeString.toLowerCase());
              bMatchesFilter = b1 || b2;
            }
            if (bMatchesFilter) {
              child.setData(ontologyProperty);
              childClass.addChild(ontologyProperty.getURI(), child);
            }
          } catch (ClassCastException e) {
            log.debug("Shouldn't happen any more: Filtering out RDFIndividual");
          }
        }
      }
      if (!stack.contains(cl)) {
        for (java.util.Iterator<OWLNamedClass> it = cl.getSubclasses(false).iterator();
            it.hasNext(); ) {
          OWLNamedClass subClass = (OWLNamedClass) it.next();
          stack.add(cl);
          standardTraverseTree(subClass, stack, childClass, applyfilter);
          stack.remove(cl);
        }
      }

      // remove nodes that don't apply the given filter
      if (applyfilter) {
        Iterator it = childClass.getChildren();
        if (it.hasNext()) {
          // ok node still has other leaf elements - keep it
        } else {
          node.removeChild(cl.getURI());
        }
      }

      return node;
    }