Skip to content

Commit

Permalink
Onboarding Application Changes for OSS (open-metadata#19203)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohityadav766 authored Jan 3, 2025
1 parent 19b5357 commit d60327c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,21 @@ public final DeleteResponse<T> delete(
return response;
}

@SuppressWarnings("unused")
@Transaction
public final DeleteResponse<T> deleteByNameIfExists(
String updatedBy, String name, boolean recursive, boolean hardDelete) {
name = quoteFqn ? quoteName(name) : name;
T entity = findByNameOrNull(name, ALL);
if (entity != null) {
DeleteResponse<T> response = deleteInternalByName(updatedBy, name, recursive, hardDelete);
postDelete(response.entity());
return response;
} else {
return new DeleteResponse<>(null, ENTITY_DELETED);
}
}

@Transaction
public final DeleteResponse<T> deleteByName(
String updatedBy, String name, boolean recursive, boolean hardDelete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.openmetadata.common.utils.CommonUtil.nullOrEmpty;
import static org.openmetadata.service.Entity.DASHBOARD;
import static org.openmetadata.service.Entity.MLMODEL;
import static org.openmetadata.service.Entity.getEntityReference;
import static org.openmetadata.service.resources.tags.TagLabelUtil.checkMutuallyExclusive;
import static org.openmetadata.service.util.EntityUtil.entityReferenceMatch;
import static org.openmetadata.service.util.EntityUtil.mlFeatureMatch;
Expand Down Expand Up @@ -149,8 +150,7 @@ private void validateReferences(List<MlFeature> mlFeatures) {

private void validateMlDataSource(MlFeatureSource source) {
if (source.getDataSource() != null) {
Entity.getEntityReferenceById(
source.getDataSource().getType(), source.getDataSource().getId(), Include.NON_DELETED);
Entity.getEntityReference(source.getDataSource(), Include.NON_DELETED);
}
}

Expand Down Expand Up @@ -211,7 +211,7 @@ private void setMlFeatureSourcesLineage(MlModel mlModel) {
.getFeatureSources()
.forEach(
mlFeatureSource -> {
EntityReference targetEntity = mlFeatureSource.getDataSource();
EntityReference targetEntity = getEntityReference(mlFeatureSource.getDataSource(), Include.ALL);
if (targetEntity != null) {
addRelationship(
targetEntity.getId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang3.tuple.Triple;
import org.jdbi.v3.sqlobject.transaction.Transaction;
import org.openmetadata.schema.EntityInterface;
Expand Down Expand Up @@ -173,8 +172,7 @@ private PipelineStatus getPipelineStatus(Pipeline pipeline) {
PipelineStatus.class);
}

public RestUtil.PutResponse<?> addPipelineStatus(
UriInfo uriInfo, String fqn, PipelineStatus pipelineStatus) {
public RestUtil.PutResponse<?> addPipelineStatus(String fqn, PipelineStatus pipelineStatus) {
// Validate the request content
Pipeline pipeline = daoCollection.pipelineDAO().findEntityByName(fqn);
pipeline.setService(getContainer(pipeline.getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public Response addPipelineStatus(
OperationContext operationContext =
new OperationContext(entityType, MetadataOperation.EDIT_STATUS);
authorizer.authorize(securityContext, operationContext, getResourceContextByName(fqn));
return repository.addPipelineStatus(uriInfo, fqn, pipelineStatus).toResponse();
return repository.addPipelineStatus(fqn, pipelineStatus).toResponse();
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -640,6 +641,24 @@ public static JsonNode pojoToJsonNode(Object obj) {
}
}

@SuppressWarnings("unused")
public static Map<String, Object> getMapFromJson(String json) {
return (Map<String, Object>) (JsonUtils.readValue(json, Map.class));
}

@SuppressWarnings("unused")
public static <T> T convertObjectWithFilteredFields(
Object input, Set<String> fields, Class<T> clazz) {
Map<String, Object> inputMap = JsonUtils.getMap(input);
Map<String, Object> result = new HashMap<>();
for (String field : fields) {
if (inputMap.containsKey(field)) {
result.put(field, inputMap.get(field));
}
}
return JsonUtils.convertValue(result, clazz);
}

public static JsonPatch convertFgeToJavax(com.github.fge.jsonpatch.JsonPatch fgeJsonPatch) {
String jsonString = fgeJsonPatch.toString();

Expand Down

0 comments on commit d60327c

Please sign in to comment.