use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testOnlyRootNodeDAG.
@Test
public void testOnlyRootNodeDAG() {
DAG dag = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
// Create invalid root node
Node rootNode = createRootNode();
graph.addVertex(rootNode);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(rootNode, graph);
dag.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
dag.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
MetacardImpl metacard = dagConverter.convertDAG(dag, false, SOURCE_ID);
assertThat(metacard.getTitle(), nullValue());
}
use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method removeNode.
private void removeNode(Graph<Node, Edge> graph, String nodeName) {
DepthFirstIterator<Node, Edge> depthFirstIterator = new DepthFirstIterator<>(graph);
List<Node> removeVertices = new ArrayList<>();
while (depthFirstIterator.hasNext()) {
depthFirstIterator.setCrossComponentTraversal(false);
Node node = depthFirstIterator.next();
if (node.attribute_name.equals(nodeName)) {
removeVertices.add(node);
}
}
removeVertices.forEach(graph::removeVertex);
}
use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testImageryViewConversion.
/**
* Test the Imagery View DAG to Metacard
*
* <p>NSIL_PRODUCT NSIL_APPROVAL NSIL_CARD NSIL_FILE NSIL_STREAM NSIL_METADATASECURITY
* NSIL_RELATED_FILE NSIL_SECURITY NSIL_PART NSIL_SECURITY NSIL_COMMON NSIL_COVERAGE
* NSIL_EXPLOITATION_INFO NSIL_IMAGERY NSIL_ASSOCIATION NSIL_RELATION NSIL_SOURCE NSIL_CARD
* NSIL_DESTINATION NSIL_CARD
*/
@Test
public void testImageryViewConversion() {
DAG imageryDAG = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
Node productNode = createRootNode();
graph.addVertex(productNode);
addCardNode(graph, productNode);
addFileNode(graph, productNode);
addMetadataSecurity(graph, productNode);
addSecurityNode(graph, productNode);
addImageryPart(graph, productNode);
addAssocationNode(graph, productNode);
addApprovalNode(graph, productNode);
addRelatedFile(graph, productNode);
graph.addVertex(productNode);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(productNode, graph);
imageryDAG.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
imageryDAG.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
MetacardImpl metacard = dagConverter.convertDAG(imageryDAG, false, SOURCE_ID);
if (SHOULD_PRINT_CARD) {
File file = new File("/tmp/output-imagery.txt");
if (file.exists()) {
file.delete();
}
try (PrintStream outStream = new PrintStream(file)) {
printMetacard(metacard, outStream);
} catch (IOException ioe) {
// Ignore the error
}
}
// Check top-level meta-card attributes
assertThat(metacard.getTitle(), is(IMAGERY_TITLE));
assertThat(metacard.getId(), is(CARD_ID));
assertThat(metacard.getCreatedDate(), notNullValue());
assertThat(metacard.getEffectiveDate(), notNullValue());
assertThat(metacard.getModifiedDate(), is(cal.getTime()));
assertThat(metacard.getDescription(), is(COM_DESCRIPTION_ABSTRACT));
assertThat(metacard.getLocation(), is(WKT_LOCATION));
assertThat(metacard.getAttribute(Core.RESOURCE_URI).getValue().toString(), is(FILE_PRODUCT_URL));
checkCommonAttributes(metacard);
checkExploitationInfoAttributes(metacard);
checkImageryAttributes(metacard);
checkSecurityAttributes(metacard);
checkCoverageAttributes(metacard);
checkAssociationAttribute(metacard);
DAGConverter.logMetacard(metacard, "123");
}
use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testSwapCoordinates.
@Test
public void testSwapCoordinates() {
String swapWktLocation = "POLYGON ((1 1, 1 5, 5 5, 5 1, 1 1))";
DAG imageryDAG = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
Node productNode = createRootNode();
graph.addVertex(productNode);
addCardNode(graph, productNode);
addFileNode(graph, productNode);
addMetadataSecurity(graph, productNode);
addSecurityNode(graph, productNode);
addImageryPart(graph, productNode);
graph.addVertex(productNode);
removeNode(graph, NsiliConstants.ADVANCED_GEOSPATIAL);
NsiliCommonUtils.setUCOEdgeIds(graph);
NsiliCommonUtils.setUCOEdges(productNode, graph);
imageryDAG.edges = NsiliCommonUtils.getEdgeArrayFromGraph(graph);
imageryDAG.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
MetacardImpl metacard = dagConverter.convertDAG(imageryDAG, true, SOURCE_ID);
if (SHOULD_PRINT_CARD) {
File file = new File("/tmp/output-imagery.txt");
if (file.exists()) {
file.delete();
}
try (PrintStream outStream = new PrintStream(file)) {
printMetacard(metacard, outStream);
} catch (IOException ioe) {
// Ignore the error
}
}
// Check top-level meta-card attributes
assertThat(metacard.getLocation(), is(swapWktLocation));
}
use of org.codice.alliance.nsili.common.UCO.Edge in project alliance by codice.
the class DAGConverterTest method testStartNodeOfEdgeNull.
@Test
public void testStartNodeOfEdgeNull() {
DAG dag = new DAG();
DirectedAcyclicGraph<Node, Edge> graph = new DirectedAcyclicGraph<>(Edge.class);
// Create invalid root node
Node rootNode = createRootNode();
graph.addVertex(rootNode);
Edge[] edges = new Edge[1];
Edge edge = new Edge(0, 1, "");
edges[0] = edge;
dag.nodes = NsiliCommonUtils.getNodeArrayFromGraph(graph);
dag.edges = edges;
MetacardImpl metacard = dagConverter.convertDAG(dag, false, SOURCE_ID);
assertThat(metacard.getTitle(), nullValue());
}
Aggregations