- if( actionVal.equals("COLLECT_DATA") ){
- // When doing COLLECT_DATA, we expect them to either pass the vertexId or
- // that the dataString string to be comma separated name value pairs like this:
- // "propName1|propVal1,propName2|propVal2" etc. We will look for a node or nodes
- // that have properties that ALL match what was passed in.
- GraphTraversal<Vertex, Vertex> g = null;
- String qStringForMsg = "";
- int resCount = 0;
- if( vertexIdLong > 0 ){
- // They know which vertex they want to look at
- qStringForMsg = "graph.vertices(" + vertexIdLong + ")";
- Iterator <Vertex> vtxItr = graph.vertices( vertexIdLong );
- if( vtxItr != null && vtxItr.hasNext() ) {
- Vertex vtx = vtxItr.next();
- fd.showNodeInfo( logger, vtx, displayAllVidsFlag );
- resCount++;
- }
- }
- else {
- // we need to find the node or nodes based on the dataString
- int firstPipeLoc = dataString.indexOf("|");
- if( firstPipeLoc <= 0 ){
- msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'";
- System.out.println(msg);
- logger.error(msg);
- exit(0);
- }
- g = graph.traversal().V();
- qStringForMsg = " graph.traversal().V()";
- // Note - if they're only passing one parameter, there won't be any commas
- String [] paramArr = dataString.split(",");
- for( int i = 0; i < paramArr.length; i++ ){
- int pipeLoc = paramArr[i].indexOf("|");
- if( pipeLoc <= 0 ){
- msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'";
- System.out.println(msg);
- logger.error(msg);
- exit(0);
- }
- else {
- String propName = paramArr[i].substring(0,pipeLoc);
- String propVal = paramArr[i].substring(pipeLoc + 1);
- g = g.has(propName,propVal);
- qStringForMsg = qStringForMsg + ".has(" + propName + "," + propVal + ")";
- }
- }
-
- if( (g != null)){
- Iterator<Vertex> vertItor = g;
- while( vertItor.hasNext() ){
- resCount++;
- Vertex v = vertItor.next();
- fd.showNodeInfo( logger, v, displayAllVidsFlag );
- int descendantCount = fd.countDescendants( logger, v, 0 );
- String infMsg = " Found " + descendantCount + " descendant nodes \n";
- System.out.println( infMsg );
- logger.debug( infMsg );
- }
- }
- else {
- msg = "Bad JanusGraphQuery object. ";
- System.out.println(msg);
- logger.error(msg);
- exit(0);
- }
- }
-
- String infMsg = "\n\n Found: " + resCount + " nodes for this query: [" + qStringForMsg + "]\n";
- System.out.println( infMsg );
- logger.debug( infMsg );
- }
- else if( actionVal.equals("DELETE_NODE") ){
- Iterator <Vertex> vtxItr = graph.vertices( vertexIdLong );
- if( vtxItr != null && vtxItr.hasNext() ) {
- Vertex vtx = vtxItr.next();
- fd.showNodeInfo( logger, vtx, displayAllVidsFlag );
- int descendantCount = fd.countDescendants( logger, vtx, 0 );
- String infMsg = " Found " + descendantCount + " descendant nodes. Note - forceDelete does not cascade to " +
- " child nodes, but they may become unreachable after the delete. \n";
- System.out.println( infMsg );
- logger.debug( infMsg );
-
- int edgeCount = fd.countEdges( logger, vtx );
-
- infMsg = " Found total of " + edgeCount + " edges incident on this node. \n";
- System.out.println( infMsg );
- logger.debug( infMsg );
-
- if( fd.getNodeDelConfirmation(logger, userIdVal, vtx, descendantCount, edgeCount, overRideProtection) ){
- vtx.remove();
- graph.tx().commit();
- infMsg = ">>>>>>>>>> Removed node with vertexId = " + vertexIdLong;
- logger.debug( infMsg );
- System.out.println(infMsg);
- }
- else {
- infMsg = " Delete Cancelled. ";
- System.out.println(infMsg);
- logger.debug( infMsg );
- }
- }
- else {
- String infMsg = ">>>>>>>>>> Vertex with vertexId = " + vertexIdLong + " not found.";
- System.out.println( infMsg );
- logger.debug( infMsg );
- }
- }
- else if( actionVal.equals("DELETE_EDGE") ){
- Edge thisEdge = null;
- Iterator <Edge> edItr = graph.edges( edgeIdStr );
- if( edItr != null && edItr.hasNext() ) {
- thisEdge = edItr.next();
- }
-
- if( thisEdge == null ){
- String infMsg = ">>>>>>>>>> Edge with edgeId = " + edgeIdStr + " not found.";
- logger.debug( infMsg );
- System.out.println(infMsg);
- exit(0);
- }
-
- if( fd.getEdgeDelConfirmation(logger, userIdVal, thisEdge, overRideProtection) ){
- thisEdge.remove();
- graph.tx().commit();
- String infMsg = ">>>>>>>>>> Removed edge with edgeId = " + edgeIdStr;
- logger.debug( infMsg );
- System.out.println(infMsg);
- }
- else {
- String infMsg = " Delete Cancelled. ";
- System.out.println(infMsg);
- logger.debug( infMsg );
- }
- exit(0);
- }
- else {
- String emsg = "Unknown action parameter [" + actionVal + "] passed to ForceDeleteTool(). Valid values = COLLECT_DATA, DELETE_NODE or DELETE_EDGE \n";
+ if (actionVal.equals("COLLECT_DATA")) {
+ // When doing COLLECT_DATA, we expect them to either pass the vertexId or
+ // that the dataString string to be comma separated name value pairs like this:
+ // "propName1|propVal1,propName2|propVal2" etc. We will look for a node or nodes
+ // that have properties that ALL match what was passed in.
+ GraphTraversal<Vertex, Vertex> g = null;
+ String qStringForMsg = "";
+ int resCount = 0;
+ if (vertexIdLong > 0) {
+ // They know which vertex they want to look at
+ qStringForMsg = "graph.vertices(" + vertexIdLong + ")";
+ Iterator<Vertex> vtxItr = graph.vertices(vertexIdLong);
+ if (vtxItr != null && vtxItr.hasNext()) {
+ Vertex vtx = vtxItr.next();
+ fd.showNodeInfo(logger, vtx, displayAllVidsFlag);
+ resCount++;
+ }
+ } else {
+ // we need to find the node or nodes based on the dataString
+ int firstPipeLoc = dataString.indexOf("|");
+ if (firstPipeLoc <= 0) {
+ msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'";
+ System.out.println(msg);
+ logger.error(msg);
+ exit(0);
+ }
+ g = graph.traversal().V();
+ qStringForMsg = " graph.traversal().V()";
+ // Note - if they're only passing one parameter, there won't be any commas
+ String[] paramArr = dataString.split(",");
+ for (int i = 0; i < paramArr.length; i++) {
+ int pipeLoc = paramArr[i].indexOf("|");
+ if (pipeLoc <= 0) {
+ msg = "Must use the -params4Collect option when collecting data with data string in a format like: 'propName1|propVal1,propName2|propVal2'";
+ System.out.println(msg);
+ logger.error(msg);
+ exit(0);
+ } else {
+ String propName = paramArr[i].substring(0, pipeLoc);
+ String propVal = paramArr[i].substring(pipeLoc + 1);
+ g = g.has(propName, propVal);
+ qStringForMsg = qStringForMsg + ".has(" + propName + "," + propVal + ")";
+ }
+ }
+
+ if ((g != null)) {
+ Iterator<Vertex> vertItor = g;
+ while (vertItor.hasNext()) {
+ resCount++;
+ Vertex v = vertItor.next();
+ fd.showNodeInfo(logger, v, displayAllVidsFlag);
+ int descendantCount = fd.countDescendants(logger, v, 0);
+ String infMsg = " Found " + descendantCount + " descendant nodes \n";
+ System.out.println(infMsg);
+ logger.debug(infMsg);
+ }
+ } else {
+ msg = "Bad JanusGraphQuery object. ";
+ System.out.println(msg);
+ logger.error(msg);
+ exit(0);
+ }
+ }
+
+ String infMsg = "\n\n Found: " + resCount + " nodes for this query: [" + qStringForMsg + "]\n";
+ System.out.println(infMsg);
+ logger.debug(infMsg);
+ } else if (actionVal.equals("DELETE_NODE")) {
+ Iterator<Vertex> vtxItr = graph.vertices(vertexIdLong);
+ if (vtxItr != null && vtxItr.hasNext()) {
+ Vertex vtx = vtxItr.next();
+ fd.showNodeInfo(logger, vtx, displayAllVidsFlag);
+ int descendantCount = fd.countDescendants(logger, vtx, 0);
+ String infMsg = " Found " + descendantCount + " descendant nodes. Note - forceDelete does not cascade to " +
+ " child nodes, but they may become unreachable after the delete. \n";
+ System.out.println(infMsg);
+ logger.debug(infMsg);
+
+ int edgeCount = fd.countEdges(logger, vtx);
+
+ infMsg = " Found total of " + edgeCount + " edges incident on this node. \n";
+ System.out.println(infMsg);
+ logger.debug(infMsg);
+
+ if (fd.getNodeDelConfirmation(logger, userIdVal, vtx, descendantCount, edgeCount, overRideProtection)) {
+ vtx.remove();
+ graph.tx().commit();
+ infMsg = ">>>>>>>>>> Removed node with vertexId = " + vertexIdLong;
+ logger.debug(infMsg);
+ System.out.println(infMsg);
+ } else {
+ infMsg = " Delete Cancelled. ";
+ System.out.println(infMsg);
+ logger.debug(infMsg);
+ }
+ } else {
+ String infMsg = ">>>>>>>>>> Vertex with vertexId = " + vertexIdLong + " not found.";
+ System.out.println(infMsg);
+ logger.debug(infMsg);
+ }
+ } else if (actionVal.equals("DELETE_EDGE")) {
+ Edge thisEdge = null;
+ Iterator<Edge> edItr = graph.edges(edgeIdStr);
+ if (edItr != null && edItr.hasNext()) {
+ thisEdge = edItr.next();
+ }
+
+ if (thisEdge == null) {
+ String infMsg = ">>>>>>>>>> Edge with edgeId = " + edgeIdStr + " not found.";
+ logger.debug(infMsg);
+ System.out.println(infMsg);
+ exit(0);
+ }
+
+ if (fd.getEdgeDelConfirmation(logger, userIdVal, thisEdge, overRideProtection)) {
+ thisEdge.remove();
+ graph.tx().commit();
+ String infMsg = ">>>>>>>>>> Removed edge with edgeId = " + edgeIdStr;
+ logger.debug(infMsg);
+ System.out.println(infMsg);
+ } else {
+ String infMsg = " Delete Cancelled. ";
+ System.out.println(infMsg);
+ logger.debug(infMsg);
+ }
+ exit(0);
+ } else {
+ String emsg = "Unknown action parameter [" + actionVal
+ + "] passed to ForceDeleteTool(). Valid values = COLLECT_DATA, DELETE_NODE or DELETE_EDGE \n";