Search in sources :

Example 56 with Node

use of org.codice.alliance.nsili.common.UCO.Node in project alliance by codice.

the class NsiliCommonUtils method setUCOEdges.

/**
 * Set the UCO.Edges of the DAG according to the NSILI Spec. This requires the ids of the Nodes to
 * be set in DFS order.
 *
 * @param root - the root node of the graph (NSIL_PRODUCT)
 * @param graph - the graph representation of the DAG
 */
public static void setUCOEdges(Node root, Graph<Node, Edge> graph) {
    if (graph != null) {
        Deque<Node> stack = new ArrayDeque<>();
        Deque<Node> visitorStack = new ArrayDeque<>();
        stack.push(root);
        while (!stack.isEmpty()) {
            Node currNode = stack.pop();
            if (!visitorStack.contains(currNode)) {
                visitorStack.push(currNode);
                for (Edge edge : graph.edgesOf(currNode)) {
                    processEdges(graph, stack, edge);
                }
            }
        }
    }
}
Also used : Node(org.codice.alliance.nsili.common.UCO.Node) Edge(org.codice.alliance.nsili.common.UCO.Edge) ArrayDeque(java.util.ArrayDeque)

Example 57 with Node

use of org.codice.alliance.nsili.common.UCO.Node in project alliance by codice.

the class NsiliCommonUtils method processEdges.

private static void processEdges(Graph<Node, Edge> graph, Deque<Node> stack, Edge edge) {
    Node source = graph.getEdgeSource(edge);
    Node target = graph.getEdgeTarget(edge);
    if (edge != null && source != null && target != null) {
        edge.start_node = source.id;
        edge.end_node = target.id;
        stack.push(target);
    }
}
Also used : Node(org.codice.alliance.nsili.common.UCO.Node)

Example 58 with Node

use of org.codice.alliance.nsili.common.UCO.Node in project alliance by codice.

the class ResultDAGConverter method addStringAttribute.

public static void addStringAttribute(DirectedAcyclicGraph<Node, Edge> graph, Node parentNode, String key, String value, ORB orb) {
    Any any = orb.create_any();
    any.insert_string(value);
    Node node = new Node(0, NodeType.ATTRIBUTE_NODE, key, any);
    graph.addVertex(node);
    graph.addEdge(parentNode, node);
}
Also used : Node(org.codice.alliance.nsili.common.UCO.Node) Any(org.omg.CORBA.Any)

Example 59 with Node

use of org.codice.alliance.nsili.common.UCO.Node in project alliance by codice.

the class ResultDAGConverter method addImageryPart.

public static List<String> addImageryPart(DirectedAcyclicGraph<Node, Edge> graph, Node partNode, Metacard metacard, ORB orb, String parentAttrName, List<String> resultAttributes) {
    List<String> addedAttributes = new ArrayList<>();
    Any imageryAny = orb.create_any();
    Node imageryNode = new Node(0, NodeType.ENTITY_NODE, NsiliConstants.NSIL_IMAGERY, imageryAny);
    graph.addVertex(imageryNode);
    graph.addEdge(partNode, imageryNode);
    String attribute = parentAttrName + NsiliConstants.NSIL_IMAGERY;
    addStrAttribute(graph, metacard.getAttribute(Core.TITLE), orb, resultAttributes, addedAttributes, imageryNode, attribute, NsiliConstants.TITLE);
    addIntAttribute(graph, metacard.getAttribute(Media.HEIGHT), orb, resultAttributes, addedAttributes, imageryNode, attribute, NsiliConstants.NUMBER_OF_ROWS);
    addIntAttribute(graph, metacard.getAttribute(Media.WIDTH), orb, resultAttributes, addedAttributes, imageryNode, attribute, NsiliConstants.NUMBER_OF_COLS);
    addDecompressionAttributes(graph, metacard, orb, resultAttributes, addedAttributes, imageryNode, attribute);
    addBandsAttribute(graph, metacard, orb, resultAttributes, addedAttributes, imageryNode, attribute);
    addDblAsIntAttribute(graph, metacard.getAttribute(Isr.NATIONAL_IMAGERY_INTERPRETABILITY_RATING_SCALE), orb, resultAttributes, addedAttributes, imageryNode, attribute, NsiliConstants.NIIRS);
    addCategoryAttribute(graph, metacard, orb, resultAttributes, addedAttributes, imageryNode, attribute, true);
    addDblAsIntAttribute(graph, metacard.getAttribute(Isr.CLOUD_COVER), orb, resultAttributes, addedAttributes, imageryNode, attribute, NsiliConstants.CLOUD_COVER_PCT);
    addIdentifierAttribute(graph, metacard, orb, resultAttributes, addedAttributes, imageryNode, attribute);
    addStrAttribute(graph, metacard.getAttribute(Isr.COMMENTS), orb, resultAttributes, addedAttributes, imageryNode, attribute, NsiliConstants.COMMENTS);
    return addedAttributes;
}
Also used : Node(org.codice.alliance.nsili.common.UCO.Node) ArrayList(java.util.ArrayList) Any(org.omg.CORBA.Any)

Example 60 with Node

use of org.codice.alliance.nsili.common.UCO.Node in project alliance by codice.

the class ResultDAGConverter method addGeomAttribute.

public static void addGeomAttribute(DirectedAcyclicGraph<Node, Edge> graph, Node parentNode, String key, Rectangle rectangle, ORB orb) {
    if (rectangle != null) {
        Any any = orb.create_any();
        RectangleHelper.insert(any, rectangle);
        Node node = new Node(0, NodeType.ATTRIBUTE_NODE, key, any);
        graph.addVertex(node);
        graph.addEdge(parentNode, node);
    }
}
Also used : Node(org.codice.alliance.nsili.common.UCO.Node) Any(org.omg.CORBA.Any)

Aggregations

Node (org.codice.alliance.nsili.common.UCO.Node)109 Any (org.omg.CORBA.Any)61 Edge (org.codice.alliance.nsili.common.UCO.Edge)31 ArrayList (java.util.ArrayList)23 DirectedAcyclicGraph (org.jgrapht.experimental.dag.DirectedAcyclicGraph)23 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)21 DAG (org.codice.alliance.nsili.common.UCO.DAG)21 Test (org.junit.Test)20 File (java.io.File)12 IOException (java.io.IOException)12 PrintStream (java.io.PrintStream)11 DepthFirstIterator (org.jgrapht.traverse.DepthFirstIterator)6 Attribute (ddf.catalog.data.Attribute)5 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 Metacard (ddf.catalog.data.Metacard)1 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1 BufferedInputStream (java.io.BufferedInputStream)1 FileOutputStream (java.io.FileOutputStream)1 Serializable (java.io.Serializable)1