|
| 1 | +package com.netflix.metacat.common.server.usermetadata; |
| 2 | +import com.netflix.metacat.common.QualifiedName; |
| 3 | +import com.netflix.metacat.common.dto.notifications.ChildInfoDto; |
| 4 | +import com.netflix.metacat.common.server.model.ChildInfo; |
| 5 | +import com.netflix.metacat.common.server.model.ParentInfo; |
| 6 | + |
| 7 | +import java.util.Set; |
| 8 | + |
| 9 | +/** |
| 10 | + * Parent-Child Relationship Metadata Service API. |
| 11 | + * |
| 12 | + * @author yingjianw |
| 13 | + */ |
| 14 | +public interface ParentChildRelMetadataService { |
| 15 | + /** |
| 16 | + * Establishes a parent-child relationship with a specified relation type. |
| 17 | + * Currently, exceptions are thrown in the following cases: |
| 18 | + * 1. Attempting to create a child table as the parent of another child table. |
| 19 | + * 2. Attempting to create a parent table on top of a parent table |
| 20 | + * 3. A child table having more than one parent. |
| 21 | + * |
| 22 | + * @param parentName the name of the parent entity |
| 23 | + * @param parentUUID the uuid of the parent |
| 24 | + * @param childName the name of the child entity |
| 25 | + * @param childUUID the uuid of the child |
| 26 | + * @param relationType the type of the relationship |
| 27 | + */ |
| 28 | + void createParentChildRelation( |
| 29 | + QualifiedName parentName, |
| 30 | + String parentUUID, |
| 31 | + QualifiedName childName, |
| 32 | + String childUUID, |
| 33 | + String relationType |
| 34 | + ); |
| 35 | + |
| 36 | + /** |
| 37 | + * Deletes a parent-child relationship with a specified relation type. |
| 38 | + * This function is only called in the recovery process when |
| 39 | + * we first create the parent-child relationship but fail to create the table. |
| 40 | + * |
| 41 | + * @param parentName the name of the parent entity |
| 42 | + * @param parentUUID the uuid of the parent |
| 43 | + * @param childName the name of the child entity |
| 44 | + * @param childUUID the uuid of the child |
| 45 | + * @param type the type of the relationship |
| 46 | + */ |
| 47 | + void deleteParentChildRelation( |
| 48 | + QualifiedName parentName, |
| 49 | + String parentUUID, |
| 50 | + QualifiedName childName, |
| 51 | + String childUUID, |
| 52 | + String type |
| 53 | + ); |
| 54 | + |
| 55 | + /** |
| 56 | + * Renames `oldName` to `newName` in the parentChildRelationship store. |
| 57 | + * This involves two steps: |
| 58 | + * 1. Rename all records where the child is `oldName` to `newName` |
| 59 | + * 2. Rename all records where the parent is `oldName` to `newName` |
| 60 | + * |
| 61 | + * @param oldName the current name to be renamed |
| 62 | + * @param newName the new name to rename to |
| 63 | + */ |
| 64 | + void rename( |
| 65 | + QualifiedName oldName, |
| 66 | + QualifiedName newName |
| 67 | + ); |
| 68 | + |
| 69 | + /** |
| 70 | + * Removes the entity from the parentChildRelationship store. |
| 71 | + * This involves two steps: |
| 72 | + * 1. drop all records where the child column = `name` |
| 73 | + * 2. drop all records where the parent column = `name` |
| 74 | + * @param name the name of the entity to drop |
| 75 | + */ |
| 76 | + void drop( |
| 77 | + QualifiedName name |
| 78 | + ); |
| 79 | + |
| 80 | + /** |
| 81 | + * get the set of parent for the input name. |
| 82 | + * @param name name |
| 83 | + * @return parentInfo |
| 84 | + */ |
| 85 | + Set<ParentInfo> getParents( |
| 86 | + QualifiedName name |
| 87 | + ); |
| 88 | + |
| 89 | + /** |
| 90 | + * get the set of children for the input name. |
| 91 | + * @param name name |
| 92 | + * @return a set of ChildInfo |
| 93 | + */ |
| 94 | + Set<ChildInfo> getChildren( |
| 95 | + QualifiedName name |
| 96 | + ); |
| 97 | + |
| 98 | + /** |
| 99 | + * get the set of children dto for the input name. |
| 100 | + * @param name name |
| 101 | + * @return a set of ChildInfo |
| 102 | + */ |
| 103 | + Set<ChildInfoDto> getChildrenDto( |
| 104 | + QualifiedName name |
| 105 | + ); |
| 106 | +} |
0 commit comments