@Override public boolean containsKeyspace(Keyspace keyspace){ //Check the local cache to see which keyspaces we already have open if(existingKeyspaces.contains(keyspace)){ return true; } try (GraknTx tx = systemKeyspaceSession.transaction(GraknTxType.READ)) { boolean keyspaceExists = (tx.getAttributeType(KEYSPACE_RESOURCE.getValue()).attribute(keyspace) != null); if(keyspaceExists) existingKeyspaces.add(keyspace); return keyspaceExists; } }
private boolean deleteReferenceInSystemKeyspace(Keyspace keyspace){ try (EmbeddedGraknTx<?> tx = systemKeyspaceSession.transaction(GraknTxType.WRITE)) { AttributeType<String> keyspaceName = tx.getSchemaConcept(KEYSPACE_RESOURCE); Attribute<String> attribute = keyspaceName.attribute(keyspace.getValue()); if(attribute == null) return false; Thing thing = attribute.owner(); if(thing != null) thing.delete(); attribute.delete(); existingKeyspaces.remove(keyspace); tx.commit(); } return true; }