示例#1
0
  /**
   * Delete transact config.
   *
   * @param childTableName child table name
   * @param childColumnName child column name
   * @param childUuid child row uuid
   * @param parentTableName parent table name
   * @param parentColumnName parent column
   */
  private void deleteConfig(
      String childTableName,
      String childColumnName,
      String childUuid,
      String parentTableName,
      String parentColumnName) {
    DatabaseSchema dbSchema = schema.get(OvsdbConstant.DATABASENAME);
    TableSchema childTableSchema = dbSchema.getTableSchema(childTableName);

    ArrayList<Operation> operations = Lists.newArrayList();
    if (parentTableName != null && parentColumnName != null) {
      TableSchema parentTableSchema = dbSchema.getTableSchema(parentTableName);
      ColumnSchema parentColumnSchema = parentTableSchema.getColumnSchema(parentColumnName);
      List<Mutation> mutations = Lists.newArrayList();
      Mutation mutation = MutationUtil.delete(parentColumnSchema.name(), UUID.uuid(childUuid));
      mutations.add(mutation);
      List<Condition> conditions = Lists.newArrayList();
      Condition condition = ConditionUtil.includes(parentColumnName, UUID.uuid(childUuid));
      conditions.add(condition);
      Mutate op = new Mutate(parentTableSchema, conditions, mutations);
      operations.add(op);
    }

    List<Condition> conditions = Lists.newArrayList();
    Condition condition = ConditionUtil.equals(childColumnName, UUID.uuid(childUuid));
    conditions.add(condition);
    Delete del = new Delete(childTableSchema, conditions);
    operations.add(del);
    transactConfig(OvsdbConstant.DATABASENAME, operations);

    return;
  }