-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yingjian Wu
committed
Jun 6, 2024
1 parent
c54dbda
commit 787f394
Showing
16 changed files
with
1,860 additions
and
16 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...ommon-server/src/main/java/com/netflix/metacat/common/server/model/BaseRelEntityInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.netflix.metacat.common.server.model; | ||
|
||
import lombok.Data; | ||
|
||
/** | ||
* ChildInfo. | ||
*/ | ||
@Data | ||
public abstract class BaseRelEntityInfo { | ||
private String name; | ||
private String relationType; | ||
private String uuid; | ||
|
||
/** | ||
Empty Constructor. | ||
*/ | ||
public BaseRelEntityInfo() { | ||
|
||
} | ||
|
||
/** | ||
Constructor with all params. | ||
@param name name of the entity | ||
@param relationType type of the relation | ||
@param uuid uuid of the entity | ||
*/ | ||
public BaseRelEntityInfo(final String name, final String relationType, final String uuid) { | ||
this.name = name; | ||
this.relationType = relationType; | ||
this.uuid = uuid; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
metacat-common-server/src/main/java/com/netflix/metacat/common/server/model/ChildInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.netflix.metacat.common.server.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
/** | ||
* ChildInfo. | ||
*/ | ||
@EqualsAndHashCode(callSuper = true) | ||
@AllArgsConstructor | ||
@Data | ||
public class ChildInfo extends BaseRelEntityInfo { | ||
/** | ||
Constructor with all params. | ||
@param name name of the entity | ||
@param relationType type of the relation | ||
@param uuid uuid of the entity | ||
*/ | ||
public ChildInfo(final String name, final String relationType, final String uuid) { | ||
super(name, relationType, uuid); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
metacat-common-server/src/main/java/com/netflix/metacat/common/server/model/ParentInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.netflix.metacat.common.server.model; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
|
||
/** | ||
* ParentInfo. | ||
*/ | ||
@EqualsAndHashCode(callSuper = true) | ||
@Data | ||
public class ParentInfo extends BaseRelEntityInfo { | ||
|
||
/** | ||
Empty Constructor. | ||
*/ | ||
public ParentInfo() { | ||
|
||
} | ||
|
||
/** | ||
Constructor with all params. | ||
@param name name of the entity | ||
@param relationType type of the relation | ||
@param uuid uuid of the entity | ||
*/ | ||
public ParentInfo(final String name, final String relationType, final String uuid) { | ||
super(name, relationType, uuid); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...rc/main/java/com/netflix/metacat/common/server/usermetadata/DefaultTableUUIDProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.netflix.metacat.common.server.usermetadata; | ||
|
||
import com.netflix.metacat.common.dto.TableDto; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Default Table UUID Provider. | ||
* | ||
* @author yingjianw | ||
*/ | ||
public class DefaultTableUUIDProvider implements TableUUIDProvider { | ||
@Override | ||
public Optional<String> getUUID(final TableDto tableDto) { | ||
return Optional.empty(); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
.../java/com/netflix/metacat/common/server/usermetadata/ParentChildRelMetadataConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.netflix.metacat.common.server.usermetadata; | ||
|
||
/** | ||
* ParentChildRelMetadataConstants. | ||
* | ||
* @author yingjianw | ||
*/ | ||
public final class ParentChildRelMetadataConstants { | ||
/** | ||
* Key specified in DefinitionMetadata that indicate the parent table name. | ||
*/ | ||
public static final String PARENTNAME = "root_table_name"; | ||
/** | ||
* During create, the key specified in DefinitionMetadata that indicates the parent table uuid. | ||
*/ | ||
public static final String PARENTUUID = "root_table_uuid"; | ||
/** | ||
* During create, the key specified in DefinitionMetadata that indicates the child table uuid. | ||
*/ | ||
public static final String CHILDUUID = "child_table_uuid"; | ||
|
||
/** | ||
* During create, the key specified in DefinitionMetadata that indicates relationType. | ||
*/ | ||
public static final String RELATIONTYPE = "relationType"; | ||
|
||
/** | ||
* During get, the key specified in DefinitionMetadata that indicates the parent child infos. | ||
*/ | ||
public static final String PARENTCHILDRELINFO = "parentChildRelationInfo"; | ||
|
||
/** | ||
* During get, the key specified in DefinitionMetadata[PARENTCHILDRELINFO] that indicates parent infos. | ||
*/ | ||
public static final String PARENTINFOS = "parentInfos"; | ||
|
||
/** | ||
* During get, the key specified in DefinitionMetadata[PARENTCHILDRELINFO] that indicates child infos. | ||
*/ | ||
public static final String CHILDINFOS = "childInfos"; | ||
|
||
private ParentChildRelMetadataConstants() { | ||
|
||
} | ||
|
||
} |
110 changes: 110 additions & 0 deletions
110
...in/java/com/netflix/metacat/common/server/usermetadata/ParentChildRelMetadataService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package com.netflix.metacat.common.server.usermetadata; | ||
import com.netflix.metacat.common.QualifiedName; | ||
import com.netflix.metacat.common.server.model.ChildInfo; | ||
import com.netflix.metacat.common.server.model.ParentInfo; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
/** | ||
* Parent-Child Relationship Metadata Service API. | ||
* | ||
* @author yingjianw | ||
*/ | ||
public interface ParentChildRelMetadataService { | ||
/** | ||
* Establishes a parent-child relationship with a specified relation type. | ||
* Currently, exceptions are thrown in the following cases: | ||
* 1. Attempting to create a child table as the parent of another child table. | ||
* 2. A child table having more than one parent. | ||
* | ||
* @param parentName the name of the parent entity | ||
* @param parentUUID the uuid of the parent | ||
* @param childName the name of the child entity | ||
* @param childUUID the uuid of the child | ||
* @param relationType the type of the relationship | ||
*/ | ||
void createParentChildRelation( | ||
QualifiedName parentName, | ||
String parentUUID, | ||
QualifiedName childName, | ||
String childUUID, | ||
String relationType | ||
); | ||
|
||
/** | ||
* Deletes a parent-child relationship with a specified relation type. | ||
* | ||
* @param parentName the name of the parent entity | ||
* @param parentUUID the uuid of the parent | ||
* @param childName the name of the child entity | ||
* @param childUUID the uuid of the child | ||
* @param type the type of the relationship | ||
*/ | ||
void deleteParentChildRelation( | ||
QualifiedName parentName, | ||
String parentUUID, | ||
QualifiedName childName, | ||
String childUUID, | ||
String type | ||
); | ||
|
||
/** | ||
* Renames `oldName` to `newName` in the parentChildRelationship store. | ||
* This involves two steps: | ||
* 1. Rename all records where the child is `oldName` to `newName` | ||
* and if the uuid is present also include it in the sql search string. | ||
* 2. Rename all records where the parent is `oldName` to `newName` | ||
* and if the uuid is present also include it in the sql search string. | ||
* For now, since a child cannot be a parent of another entity, only one of these actions will need to be performed. | ||
* | ||
* @param oldName the current name to be renamed | ||
* @param newName the new name to rename to | ||
* @param uuid the uuid of the table | ||
*/ | ||
void rename( | ||
QualifiedName oldName, | ||
QualifiedName newName, | ||
Optional<String> uuid | ||
); | ||
|
||
/** | ||
* Removes the entity from the parentChildRelationship store. | ||
* An exception is thrown if an attempt is made to drop a parent table that still has existing child tables. | ||
* Note that only dropping a child table will result in the physical deletion of records. | ||
* When all children of a parent table are dropped, no records remain. | ||
* Consequently, at then time when dropping the parent table, there should not have any database records | ||
* with a parent reference to the dropping parent table. | ||
* | ||
* @param name the name of the entity to drop | ||
* @param uuid the uuid of the entity | ||
*/ | ||
void drop( | ||
QualifiedName name, | ||
Optional<String> uuid | ||
); | ||
|
||
/** | ||
* get the set of parent for the input name. | ||
* | ||
* @param name name | ||
* @param uuid the uuid of the entity | ||
* @return parentInfo | ||
*/ | ||
Set<ParentInfo> getParents( | ||
QualifiedName name, | ||
Optional<String> uuid | ||
); | ||
|
||
/** | ||
* get the set of children for the input name. | ||
* | ||
* @param name name | ||
* @param uuid the uuid of the entity | ||
* @return a set of ChildInfo | ||
*/ | ||
Set<ChildInfo> getChildren( | ||
QualifiedName name, | ||
Optional<String> uuid | ||
); | ||
} |
18 changes: 18 additions & 0 deletions
18
...erver/src/main/java/com/netflix/metacat/common/server/usermetadata/TableUUIDProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.netflix.metacat.common.server.usermetadata; | ||
|
||
import com.netflix.metacat.common.dto.TableDto; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Interface for TableUUIDPorvider. | ||
* @author yingjianw | ||
*/ | ||
public interface TableUUIDProvider { | ||
/** | ||
* Given a tableDto, get the corresponding table uuid if applicable. | ||
* @param tableDto dto for table | ||
* @return the uuid of the table | ||
**/ | ||
Optional<String> getUUID(TableDto tableDto); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.