# Materializing Virtual Graphs via JAVA API

**URL:** <https://community.stardog.com/t/materializing-virtual-graphs-via-java-api/175>\
**Category:** Feature Request\
**Created:** [March 14, 2017, 10:00am UTC](https://community.stardog.com/t/materializing-virtual-graphs-via-java-api/175 "2017-03-14T10:00:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PiotrNowara](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PiotrNowara](https://community.stardog.com/u/PiotrNowara)\
**Post date:** [March 14, 2017, 10:00am UTC](https://community.stardog.com/t/materializing-virtual-graphs-via-java-api/175/1 "2017-03-14T10:00:39Z")

</div>

Hi,

is there a JAVA API equivalent of "$ stardog-admin virtual import" command? I can't find it...

It would be good if VirtualGraphAdminConnection class[1] would have a method for materializing a Virtual Graph (or CSV data).

Thanks,  
Piotr

[1][404 | Stardog Documentation Latest](https://docs.stardog.com/java/snarl/com/complexible/stardog/virtual/api/admin/VirtualGraphAdminConnection.html)

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [March 14, 2017, 12:58pm UTC](https://community.stardog.com/t/materializing-virtual-graphs-via-java-api/175/2 "2017-03-14T12:58:44Z")

</div>

Hi Piotr,

In general, the functionality of CLI commands is available in Java APIs. In fact, this is how we implement the CLI commands. Some CLI commands are provided purely as convenience. These tend not to be available in APIs as they only facilitate command line convenience. The `virtual import` command is one such command added purely for convenience. It’s implementation involves:

- Adding the virtual graph to the registry
- Execute the SPARQL update `COPY <virtual://x> to <other_named_graph>`
- (or `ADD` if `--remove-all` switch is given)
- Remove the virtual graph from the registry

In short, you can use the `COPY` statement in the same manner we do here.

Jess

---

<div class="post-metadata">

**Author:** ![PiotrNowara](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@PiotrNowara](https://community.stardog.com/u/PiotrNowara)\
**Post date:** [March 14, 2017, 2:05pm UTC](https://community.stardog.com/t/materializing-virtual-graphs-via-java-api/175/3 "2017-03-14T14:05:06Z")

</div>

Hi Jess,

thanks for your explanation. I’ll try to do what you suggest.

Piotr
