Skip to content
Snippets Groups Projects
Commit dfa065b5 authored by Sara Bertocco's avatar Sara Bertocco
Browse files

Added missing methods

parent 12d3aa54
No related branches found
No related tags found
No related merge requests found
Pipeline #1053 failed
......@@ -9,6 +9,9 @@ import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import net.ivoa.xml.vospace.v2.ContainerNode;
import net.ivoa.xml.vospace.v2.DataNode;
import net.ivoa.xml.vospace.v2.StructuredDataNode;
public class NodeUtils {
......@@ -163,5 +166,62 @@ public class NodeUtils {
return true;
}
public static String getDbNodeType(Node node) {
if (node instanceof ContainerNode) {
return "container";
} else if (node instanceof DataNode) {
return "data";
}
throw new UnsupportedOperationException("Unable to retrieve database node type for class " + node.getClass().getCanonicalName());
}
public static String getNodeName(String path) {
String[] parsedPath = path.split("/");
return parsedPath[parsedPath.length - 1];
}
public static String getNodeName(Node myNode) {
String uri = myNode.getUri();
return getNodeName(uri);
}
public static boolean getIsBusy(Node myNode) {
if (myNode instanceof DataNode) {
DataNode dataNode = (DataNode) myNode;
return dataNode.isBusy();
}
return false;
}
public static Node getTypedNode(String type) {
Node node;
switch (type) {
case "container":
node = new ContainerNode();
break;
case "data":
node = new DataNode();
break;
case "structured":
node = new StructuredDataNode();
break;
default:
throw new UnsupportedOperationException("Node type " + type + " not supported yet");
}
return node;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment