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);
}
Aggregations