Search in sources :

Example 71 with Node

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

the class ResultDAGConverter method addReportPart.

public static List<String> addReportPart(DirectedAcyclicGraph<Node, Edge> graph, Node partNode, Metacard metacard, ORB orb, String parentAttrName, List<String> resultAttributes) {
    List<String> addedAttributes = new ArrayList<>();
    Any reportAny = orb.create_any();
    Node reportNode = new Node(0, NodeType.ENTITY_NODE, NsiliConstants.NSIL_REPORT, reportAny);
    graph.addVertex(reportNode);
    graph.addEdge(partNode, reportNode);
    String attribute = parentAttrName + NsiliConstants.NSIL_REPORT;
    addStrAttribute(graph, metacard.getAttribute(Isr.REPORT_SERIAL_NUMBER), orb, resultAttributes, addedAttributes, reportNode, attribute, NsiliConstants.ORIGINATORS_REQ_SERIAL_NUM);
    addTypeAttribute(graph, metacard, orb, resultAttributes, addedAttributes, reportNode, attribute);
    addStrAttribute(graph, metacard.getAttribute(Isr.REPORT_INFO_RATING), orb, resultAttributes, addedAttributes, reportNode, attribute, NsiliConstants.INFORMATION_RATING);
    addPriorityAttribute(graph, metacard, orb, resultAttributes, addedAttributes, reportNode, attribute);
    addedAttributes.addAll(addIntRepPart(graph, reportNode, metacard, orb, attribute + ":", resultAttributes));
    addedAttributes.addAll(addEntityPart(graph, reportNode, metacard, orb, attribute + ":", resultAttributes));
    return addedAttributes;
}
Also used : Node(org.codice.alliance.nsili.common.UCO.Node) ArrayList(java.util.ArrayList) Any(org.omg.CORBA.Any)

Example 72 with Node

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

the class ResultDAGConverter method addIntRepPart.

public static List<String> addIntRepPart(DirectedAcyclicGraph<Node, Edge> graph, Node partNode, Metacard metacard, ORB orb, String parentAttrName, List<String> resultAttributes) {
    List<String> addedAttributes = new ArrayList<>();
    Any intRepAny = orb.create_any();
    Node intRepNode = new Node(0, NodeType.ENTITY_NODE, NsiliConstants.NSIL_INTREP, intRepAny);
    graph.addVertex(intRepNode);
    graph.addEdge(partNode, intRepNode);
    String attribute = parentAttrName + NsiliConstants.NSIL_INTREP;
    if (shouldAdd(buildAttr(attribute, NsiliConstants.SITUATION_TYPE), resultAttributes)) {
        Attribute situationTypeAttr = metacard.getAttribute(Isr.REPORT_SITUATION_TYPE);
        if (situationTypeAttr != null) {
            String situationType = getIntRepSituationType(situationTypeAttr.getValue());
            if (situationType != null) {
                addStringAttribute(graph, intRepNode, NsiliConstants.SITUATION_TYPE, situationType, orb);
                addedAttributes.add(buildAttr(attribute, NsiliConstants.SITUATION_TYPE));
            }
        }
    }
    return addedAttributes;
}
Also used : Attribute(ddf.catalog.data.Attribute) Node(org.codice.alliance.nsili.common.UCO.Node) ArrayList(java.util.ArrayList) Any(org.omg.CORBA.Any)

Example 73 with Node

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

the class DAGConverter method printDAG.

public static void printDAG(DAG dag) {
    if (dag.nodes != null && dag.edges != null) {
        Map<Integer, Node> nodeMap = ResultDAGConverter.createNodeMap(dag.nodes);
        DirectedAcyclicGraph<Node, Edge> graph = getNodeEdgeDirectedAcyclicGraph(dag, nodeMap);
        DepthFirstIterator<Node, Edge> depthFirstIterator = new DepthFirstIterator<>(graph);
        Node rootNode = null;
        while (depthFirstIterator.hasNext()) {
            depthFirstIterator.setCrossComponentTraversal(false);
            Node node = depthFirstIterator.next();
            if (rootNode == null) {
                rootNode = node;
            }
            DijkstraShortestPath<Node, Edge> path = new DijkstraShortestPath<>(graph, rootNode, node);
            printNode(node, (int) Math.round(path.getPathLength()));
        }
    }
}
Also used : DepthFirstIterator(org.jgrapht.traverse.DepthFirstIterator) Node(org.codice.alliance.nsili.common.UCO.Node) Edge(org.codice.alliance.nsili.common.UCO.Edge) DijkstraShortestPath(org.jgrapht.alg.DijkstraShortestPath)

Example 74 with Node

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

the class DAGConverter method isNodeChildOfStart.

/**
 * Determines if the end node is a child of the start node.
 *
 * @param graph - The complete graph.
 * @param start - Starting node.
 * @param end - Child node to check
 * @return true if the end node is a child of the start node in the provided graph.
 */
private static boolean isNodeChildOfStart(DirectedAcyclicGraph<Node, Edge> graph, Node start, Node end) {
    boolean endNodeInTree = false;
    DepthFirstIterator<Node, Edge> depthFirstIterator = new DepthFirstIterator<>(graph, start);
    while (depthFirstIterator.hasNext()) {
        Node currNode = depthFirstIterator.next();
        if (currNode.id == end.id) {
            endNodeInTree = true;
        }
    }
    return endNodeInTree;
}
Also used : DepthFirstIterator(org.jgrapht.traverse.DepthFirstIterator) Node(org.codice.alliance.nsili.common.UCO.Node) Edge(org.codice.alliance.nsili.common.UCO.Edge)

Example 75 with Node

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

the class DAGConverterTest method addRFINode.

private void addRFINode(DirectedAcyclicGraph<Node, Edge> graph, Node parentNode) {
    Any rfiAny = orb.create_any();
    Node rfiNode = new Node(0, NodeType.ENTITY_NODE, NsiliConstants.NSIL_RFI, rfiAny);
    graph.addVertex(rfiNode);
    graph.addEdge(parentNode, rfiNode);
    ResultDAGConverter.addStringAttribute(graph, rfiNode, NsiliConstants.FOR_ACTION, RFI_FOR_ACTION, orb);
    ResultDAGConverter.addStringAttribute(graph, rfiNode, NsiliConstants.FOR_INFORMATION, RFI_FOR_INFORMATION, orb);
    ResultDAGConverter.addStringAttribute(graph, rfiNode, NsiliConstants.SERIAL_NUMBER, RFI_SERIAL_NUM, orb);
    ResultDAGConverter.addStringAttribute(graph, rfiNode, NsiliConstants.STATUS, RFI_STATUS, orb);
    ResultDAGConverter.addStringAttribute(graph, rfiNode, NsiliConstants.WORKFLOW_STATUS, RFI_WORKFLOW_STATUS, orb);
}
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