Package org.exist.dom

Examples of org.exist.dom.AVLTreeNodeSet$Node


    boolean status(final List<String> toks) {
        if (standaloneNodes.size() > 0) {
            out.println("Standalone Nodes:");
            for (String nodeName : standaloneNodes.keySet()) {
                Node node = standaloneNodes.get(nodeName);
                for (String curi : node.getInstalledContributions()) {
                    for (String dc : node.getDeployedComposites(curi)) {
                        out.println("   " + nodeName + " " + dc);
                    }
                }
            }
            out.println();
        }
        if (nodes.size() > 0) {
            for (Node node : nodes.values()) {
                out.println("Domain: " + node.getDomainName());
                List<String> ics;
                if (toks.size() > 1) {
                    ics = new ArrayList<String>();
                    ics.add(toks.get(1));
                } else {
                    ics = node.getInstalledContributions();
                }

                for (String curi : ics) {
                    Contribution c = node.getInstalledContribution(curi);
                    List<String> dcs = node.getDeployedComposites(curi);
                    if (toks.size() > 2) {
                        dcs = new ArrayList<String>();
                        dcs.add(toks.get(2));
                    } else {
                        dcs = node.getDeployedComposites(curi);
                    }
                    for (String compositeUri : dcs) {
                        for (Artifact a : c.getArtifacts()) {
                            if (compositeUri.equals(a.getURI())) {
                                out.println("   " + curi
View Full Code Here


      {return NodeSet.EMPTY_SET;}
        // for this method to work, all items have to be nodes
    if(itemType != Type.ANY_TYPE && Type.subTypeOf(itemType, Type.NODE)) {
      //Was ExtArrayNodeset() which orders the nodes in document order
      //The order seems to change between different invocations !!!
      final NodeSet set = new AVLTreeNodeSet();
      //We can't make it from an ExtArrayNodeSet (probably because it is sorted ?)
      //NodeSet set = new ArraySet(100);
      for (int i = 0; i < items.length; i++) {
        //TODO : investigate why we could have null here
        if (items[i] != null) {
       
          NodeValue v = (NodeValue)items[i].item;
          if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) {

                      // found an in-memory document
                      final org.exist.memtree.DocumentImpl doc = ((NodeImpl)v).getDocument();
                        if (doc==null) {
                            continue;
                        }
                        // make this document persistent: doc.makePersistent()
                        // returns a map of all root node ids mapped to the corresponding
                        // persistent node. We scan the current sequence and replace all
                        // in-memory nodes with their new persistent node objects.
                        final DocumentImpl expandedDoc = doc.expandRefs(null);
                        final org.exist.dom.DocumentImpl newDoc = expandedDoc.makePersistent();
                        if (newDoc != null) {
                            NodeId rootId = newDoc.getBrokerPool().getNodeFactory().createInstance();
                            for (int j = i; j < count; j++) {
                                v = (NodeValue) items[j].item;
                                if(v.getImplementationType() != NodeValue.PERSISTENT_NODE) {
                                    NodeImpl node = (NodeImpl) v;
                                    if (node.getDocument() == doc) {
                                        node = expandedDoc.getNode(node.getNodeNumber());
                                        NodeId nodeId = node.getNodeId();
                                        if (nodeId == null)
                                            {throw new XPathException("Internal error: nodeId == null");}
                                        if (node.getNodeType() == Node.DOCUMENT_NODE)
                                            {nodeId = rootId;}
                                        else
                                            {nodeId = rootId.append(nodeId);}
                                        NodeProxy p = new NodeProxy(newDoc, nodeId, node.getNodeType());
                                        if (p != null) {
                                            // replace the node by the NodeProxy
                                            items[j].item = p;
                                        }
                                    }
                                }
                            }
                        }
                        set.add((NodeProxy) items[i].item);
          } else {
            set.add((NodeProxy)v);
          }
        }
      }     
      return set;
    } else
View Full Code Here

    }
    if (!itemsRemoved) return;
    // Code inlined from org.exist.xquery.XPathUtil to avoid creating temporary lists
    boolean nodesOnly = true;
    for (Item item : items) if (!(item instanceof Node)) {nodesOnly = false; break;}
    seq = nodesOnly ? new AVLTreeNodeSet() : new ValueSequence();
    try {
      for (Item item : items) seq.add(item.item);
    } catch (XPathException e) {
      throw new DatabaseException(e);
    }
View Full Code Here

        else if (obj instanceof Long)
            {return new IntegerValue(((Long) obj).longValue(), Type.LONG);}
        else if (obj instanceof byte[])
            {return BinaryValueFromInputStream.getInstance(context, new Base64BinaryValueType(), new ByteArrayInputStream((byte[]) obj));}
        else if (obj instanceof ResourceSet) {
            final Sequence seq = new AVLTreeNodeSet();
            try {
                final DBBroker broker = context.getBroker();
                for(final ResourceIterator it = ((ResourceSet)obj).getIterator(); it.hasMoreResources();) {
                    seq.add(getNode(broker, (XMLResource)it.nextResource()));
                }
            } catch (final XMLDBException xe) {
                throw new XPathException("Failed to convert ResourceSet to node: " + xe.getMessage());
            }
            return seq;
        } else if (obj instanceof XMLResource) {
            return getNode(context.getBroker(), (XMLResource)obj);
        } else if (obj instanceof Node) {
            final DOMStreamer streamer = (DOMStreamer) SerializerPool.getInstance().borrowObject(DOMStreamer.class);
            try {
                final MemTreeBuilder builder = new MemTreeBuilder(context);
                builder.startDocument();
                final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(
                        builder);
                streamer.setContentHandler(receiver);
                streamer.serialize((Node) obj, false);
                return builder.getDocument().getNode(1);
            } catch (final SAXException e) {
                throw new XPathException(
                        "Failed to transform node into internal model: "
                                + e.getMessage());
            } finally {
                SerializerPool.getInstance().returnObject(streamer);
            }
        } else if (obj instanceof List<?>) {
            boolean createNodeSequence = true;
            Object next;
            for (final Iterator<?> i = ((List<?>) obj).iterator(); i.hasNext();) {
                next = i.next();
                if (!(next instanceof NodeProxy))
                    {createNodeSequence = false;}
            }
            Sequence seq = null;
            if (createNodeSequence)
                {seq = new AVLTreeNodeSet();}
            else
                {seq = new ValueSequence();}
            for (final Iterator<?> i = ((List<?>) obj).iterator(); i.hasNext();) {
                seq.add((Item) javaObjectToXPath(i.next(), context, expandChars));
            }
            return seq;
        } else if (obj instanceof NodeList) {
            final DOMStreamer streamer = (DOMStreamer) SerializerPool.getInstance().borrowObject(DOMStreamer.class);
            try {
                final MemTreeBuilder builder = new MemTreeBuilder();
                builder.startDocument();
                final DocumentBuilderReceiver receiver = new DocumentBuilderReceiver(
                        builder);
                streamer.setContentHandler(receiver);
                final ValueSequence seq = new ValueSequence();
                final NodeList nl = (NodeList) obj;
                int last = builder.getDocument().getLastNode();
                for (int i = 0; i < nl.getLength(); i++) {
                    final Node n = nl.item(i);
                    streamer.serialize(n, false);
                    final NodeImpl created = builder.getDocument().getNode(last + 1);
                    seq.add(created);
                    last = builder.getDocument().getLastNode();
                }
                return seq;
            } catch (final SAXException e) {
                throw new XPathException(
                        "Failed to transform node into internal model: "
                                + e.getMessage());
            } finally {
                SerializerPool.getInstance().returnObject(streamer);
            }
        } else if (obj instanceof Object[]) {
            boolean createNodeSequence = true;
            final Object[] array = (Object[]) obj;
            for (int i = 0; i < array.length; i++) {
                if (!(array[i] instanceof NodeProxy))
                    {createNodeSequence = false;}
            }
            Sequence seq = null;
            if (createNodeSequence)
                {seq = new AVLTreeNodeSet();}
            else
                {seq = new ValueSequence();}
            for (int i = 0; i < array.length; i++) {
                seq.add((Item) javaObjectToXPath(array[i], context, expandChars));
            }
            return seq;
        } else
            {return new JavaObjectValue(obj);}
    }
View Full Code Here

    for (Way way : waysById.values()) {
     
      List<WayNode> origWayNodes = way.getWayNodes();
      List<OSMNode> wayNodes = new ArrayList<OSMNode>(origWayNodes.size());
      for (WayNode origWayNode : origWayNodes) {
        Node origNode = nodesById.get(origWayNode.getNodeId());
        if (origNode != null) {
          wayNodes.add(nodeMap.get(origNode));
        }
      }
     
View Full Code Here

    for (Way way : waysById.values()) {
     
      List<WayNode> origWayNodes = way.getWayNodes();
      List<OwnNode> wayNodes = new ArrayList<OwnNode>(origWayNodes.size());
      for (WayNode origWayNode : origWayNodes) {
        Node origNode = nodesById.get(origWayNode.getNodeId());
        wayNodes.add(nodeMap.get(origNode));
      }
     
      OwnWay ownWay = new OwnWay(tagGroupForEntity(way), wayNodes);
     
View Full Code Here

        CommonEntityData entityData = new CommonEntityData(id, version, timestamp, osmuser,
                changeset, tags);
        if (type.equals(OSMUtils.nodeType())) {
            Point pt = (Point) feature.getDefaultGeometryProperty().getValue();
            entity = new Node(entityData, pt.getY(), pt.getX());

        } else {
            List<WayNode> nodes = Lists.newArrayList();
            String nodesString = (String) feature.getAttribute("nodes");
            for (String s : nodesString.split(";")) {
View Full Code Here

  /* save */

  @Test
  public void saveNode() {
    // Setup
    Node node = OsmDataBuilder.buildSampleNode();

    // Action
    entityDao.save(node);
    refresh(INDEX_NAME);

View Full Code Here

  }

  @Test
  public void saveAll() throws InterruptedException {
    // Setup
    Node node1 = OsmDataBuilder.buildSampleNode(1);
    Node node2 = OsmDataBuilder.buildSampleNode(2);

    // Action
    entityDao.saveAll(Arrays.asList(new Entity[] { node1, node2 }));
    refresh(INDEX_NAME);
View Full Code Here

public class ESNodeUTest {

  @Test
  public void buildFromNodeEntity() {
    // Setup
    Node node = mock(Node.class);
    when(node.getId()).thenReturn(1l);
    List<Tag> tags = new ArrayList<Tag>();
    tags.add(new Tag("highway", "primary"));
    when(node.getTags()).thenReturn(tags);
    when(node.getLatitude()).thenReturn(1.0);
    when(node.getLongitude()).thenReturn(2.0);

    ESNode expected = ESNode.Builder.create().id(1l).location(1.0, 2.0)
        .addTag("highway", "primary").build();

    // Action
View Full Code Here

TOP

Related Classes of org.exist.dom.AVLTreeNodeSet$Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.