Search in sources :

Example 1 with Delete

use of org.onosproject.ovsdb.rfc.operations.Delete in project onos by opennetworkinglab.

the class DefaultOvsdbClient method deleteConfig.

/**
 * 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
 * @param referencedValue  referenced value
 */
private void deleteConfig(String childTableName, String childColumnName, String childUuid, String parentTableName, String parentColumnName, Object referencedValue) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    TableSchema childTableSchema = dbSchema.getTableSchema(childTableName);
    ArrayList<Operation> operations = Lists.newArrayList();
    if (parentTableName != null && parentColumnName != null && referencedValue != null) {
        TableSchema parentTableSchema = dbSchema.getTableSchema(parentTableName);
        ColumnSchema parentColumnSchema = parentTableSchema.getColumnSchema(parentColumnName);
        List<Mutation> mutations = Lists.newArrayList();
        Mutation mutation = MutationUtil.delete(parentColumnSchema.name(), referencedValue);
        mutations.add(mutation);
        List<Condition> conditions = Lists.newArrayList();
        Condition condition = ConditionUtil.includes(parentColumnName, referencedValue);
        conditions.add(condition);
        Mutate op = new Mutate(parentTableSchema, conditions, mutations);
        operations.add(op);
    }
    List<Condition> conditions = Lists.newArrayList();
    Condition condition = ConditionUtil.isEqual(childColumnName, Uuid.uuid(childUuid));
    conditions.add(condition);
    Delete del = new Delete(childTableSchema, conditions);
    operations.add(del);
    transactConfig(DATABASENAME, operations);
}
Also used : Condition(org.onosproject.ovsdb.rfc.notation.Condition) Delete(org.onosproject.ovsdb.rfc.operations.Delete) TableSchema(org.onosproject.ovsdb.rfc.schema.TableSchema) ColumnSchema(org.onosproject.ovsdb.rfc.schema.ColumnSchema) Mutate(org.onosproject.ovsdb.rfc.operations.Mutate) Operation(org.onosproject.ovsdb.rfc.operations.Operation) Mutation(org.onosproject.ovsdb.rfc.notation.Mutation) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Aggregations

Condition (org.onosproject.ovsdb.rfc.notation.Condition)1 Mutation (org.onosproject.ovsdb.rfc.notation.Mutation)1 Delete (org.onosproject.ovsdb.rfc.operations.Delete)1 Mutate (org.onosproject.ovsdb.rfc.operations.Mutate)1 Operation (org.onosproject.ovsdb.rfc.operations.Operation)1 ColumnSchema (org.onosproject.ovsdb.rfc.schema.ColumnSchema)1 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)1 TableSchema (org.onosproject.ovsdb.rfc.schema.TableSchema)1