/** * Ensures that the schema exists. * * @param schemaName The schema to create if it does not exist. */ public Schema ensureSchemaExist(final String schemaName) { Optional<Schema> schemaOptional = this.getSchema(schemaName); Schema schema; if (!schemaOptional.isPresent()) { this.lock(); //search again after the lock is obtained. schemaOptional = this.getSchema(schemaName); if (!schemaOptional.isPresent()) { //create the schema and the vertex label. schema = Schema.createSchema(this.sqlgGraph, this, schemaName); this.uncommittedRemovedSchemas.remove(schemaName); this.uncommittedSchemas.put(schemaName, schema); fire(schema, "", TopologyChangeAction.CREATE); return schema; } else { return schemaOptional.get(); } } else { return schemaOptional.get(); } }
/** * Ensures that the schema exists. * * @param schemaName The schema to create if it does not exist. */ public Schema ensureSchemaExist(final String schemaName) { Optional<Schema> schemaOptional = this.getSchema(schemaName); Schema schema; if (!schemaOptional.isPresent()) { this.lock(); //search again after the lock is obtained. schemaOptional = this.getSchema(schemaName); if (!schemaOptional.isPresent()) { //create the schema and the vertex label. schema = Schema.createSchema(this.sqlgGraph, this, schemaName); this.uncommittedRemovedSchemas.remove(schemaName); this.uncommittedSchemas.put(schemaName, schema); fire(schema, "", TopologyChangeAction.CREATE); return schema; } else { return schemaOptional.get(); } } else { return schemaOptional.get(); } }