Skip to content

Commit

Permalink
add search endpoint for getParents
Browse files Browse the repository at this point in the history
  • Loading branch information
Yingjian Wu committed Jul 5, 2024
1 parent c91c57e commit 084e314
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import javax.ws.rs.PathParam;

import javax.ws.rs.core.MediaType;
import com.netflix.metacat.common.dto.notifications.ChildInfoDto;
import com.netflix.metacat.common.dto.ChildInfoDto;
import com.netflix.metacat.common.dto.ParentInfoDto;

import java.util.Set;

Expand Down Expand Up @@ -40,4 +41,24 @@ Set<ChildInfoDto> getChildren(
@PathParam("table-name")
String tableName
);

/**
* Return the list of parent.
* @param catalogName catalogName
* @param databaseName databaseName
* @param tableName tableName
* @return list of parent info dtos
*/
@GET
@Path("parents/catalog/{catalog-name}/database/{database-name}/table/{table-name}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
Set<ParentInfoDto> getParents(
@PathParam("catalog-name")
String catalogName,
@PathParam("database-name")
String databaseName,
@PathParam("table-name")
String tableName
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
import com.netflix.metacat.common.dto.Sort;
import com.netflix.metacat.common.dto.StorageDto;
import com.netflix.metacat.common.dto.TableDto;
import com.netflix.metacat.common.dto.notifications.ChildInfoDto;
import com.netflix.metacat.common.dto.ChildInfoDto;
import com.netflix.metacat.common.dto.ParentInfoDto;
import com.netflix.metacat.common.server.connectors.ConnectorRequestContext;
import com.netflix.metacat.common.server.connectors.model.AuditInfo;
import com.netflix.metacat.common.server.connectors.model.CatalogInfo;
Expand All @@ -48,6 +49,7 @@
import com.netflix.metacat.common.server.connectors.model.StorageInfo;
import com.netflix.metacat.common.server.connectors.model.TableInfo;
import com.netflix.metacat.common.server.model.ChildInfo;
import com.netflix.metacat.common.server.model.ParentInfo;
import lombok.NonNull;
import org.dozer.CustomConverter;
import org.dozer.DozerBeanMapper;
Expand Down Expand Up @@ -287,4 +289,14 @@ public PartitionsSaveResponseDto toPartitionsSaveResponseDto(final PartitionsSav
public ChildInfoDto toChildInfoDto(final ChildInfo childInfo) {
return mapper.map(childInfo, ChildInfoDto.class);
}

/**
* Convert ParentInfo to ParentInfoDto.
*
* @param parentInfo parentInfo
* @return parentInfo dto
*/
public ParentInfoDto toParentInfoDto(final ParentInfo parentInfo) {
return mapper.map(parentInfo, ParentInfoDto.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.netflix.metacat.common.server.usermetadata;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.notifications.ChildInfoDto;
import com.netflix.metacat.common.dto.ChildInfoDto;
import com.netflix.metacat.common.dto.ParentInfoDto;
import com.netflix.metacat.common.server.model.ChildInfo;
import com.netflix.metacat.common.server.model.ParentInfo;

Expand Down Expand Up @@ -98,12 +99,19 @@ Set<ChildInfo> getChildren(
/**
* get the set of children dto for the input name.
* @param name name
* @return a set of ChildInfo
* @return a set of ChildInfo dto
*/
Set<ChildInfoDto> getChildrenDto(
QualifiedName name
);

/**
* get the set of parent dto for the input name.
* @param name name
* @return a set of parentInfo dto
*/
Set<ParentInfoDto> getParentsDto(QualifiedName name);

/**
* return whether the table is a parent.
* @param tableName tableName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.netflix.metacat.common.dto.notifications;
package com.netflix.metacat.common.dto;

import com.netflix.metacat.common.dto.BaseDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -9,7 +8,7 @@
import lombok.NoArgsConstructor;

/**
* ChildInfo information.
* ChildInfo dto information.
*/
@SuppressWarnings("unused")
@Data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.netflix.metacat.common.dto;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
* ParentInfo dto information.
*/
@SuppressWarnings("unused")
@Data
@EqualsAndHashCode(callSuper = false)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ParentInfoDto extends BaseDto {
private static final long serialVersionUID = 8121239864203088788L;
/* Name of the parent */
@ApiModelProperty(value = "name of the child")
private String name;
/* Type of the relation */
@ApiModelProperty(value = "type of the relation")
private String relationType;
/* uuid of the table */
@ApiModelProperty(value = "uuid of the table")
private String uuid;
}
Loading

0 comments on commit 084e314

Please sign in to comment.