Skip to content

Commit

Permalink
Merge pull request #8520 from mandy-chessell/oak2024
Browse files Browse the repository at this point in the history
Add getAnchoredElementsGraph
  • Loading branch information
mandy-chessell authored Dec 3, 2024
2 parents 1f84eff + 3e6a38d commit 0c09057
Show file tree
Hide file tree
Showing 19 changed files with 1,105 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public AssetGraphResponse getAssetGraph(String serverName,


/**
* constructing the mermaid graph for the retrieved asset.
* Constructing the mermaid graph for the retrieved asset.
*
* @param assetGraph retrieved asset graph
* @return mermaid string
Expand Down Expand Up @@ -450,7 +450,7 @@ private String removeSpaces(String currentQualifiedName)


/**
* constructing the mermaid graph for the retrieved asset.
* Constructing the mermaid graph for the retrieved asset.
*
* @param assetLineageGraph retrieved asset graph
* @return mermaid string
Expand Down Expand Up @@ -559,6 +559,7 @@ private String getListLabel(List<String> labelValues)
return "";
}


/**
* Return all the elements that are linked to an asset using lineage relationships. The relationships are
* retrieved both from the asset, and the anchored schema elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ public String getTableDescription()
*
* @return list of columns
*/
@Override
public List<PostgreSQLColumn> getPrimaryKeys()
{
if (primaryKeys != null)
Expand Down Expand Up @@ -702,6 +703,11 @@ public static List<PostgreSQLTable> getTables()
}


/**
* Standard toString method.
*
* @return JSON style description of variables.
*/
@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ private void processDataProfileLogAnnotations(String surve
{
Map<String, Integer> measurementValues = new HashMap<>();

for (int recordNumber = 0; recordNumber < csvFileStoreConnector.getRecordCount(); recordNumber ++)
for (long recordNumber = 0; recordNumber < csvFileStoreConnector.getRecordCount(); recordNumber ++)
{
List<String> recordValues = csvFileStoreConnector.readRecord(recordNumber);

Expand Down Expand Up @@ -964,7 +964,7 @@ private void processFileClassifiers(String surveyReportGUI

if (connector instanceof CSVFileStoreConnector csvFileStoreConnector)
{
for (int recordNumber = 0; recordNumber < csvFileStoreConnector.getRecordCount(); recordNumber ++)
for (long recordNumber = 0; recordNumber < csvFileStoreConnector.getRecordCount(); recordNumber ++)
{
List<String> recordValues = csvFileStoreConnector.readRecord(recordNumber);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ public String getTableDescription()
*
* @return list of columns
*/
@Override
public List<PostgreSQLColumn> getPrimaryKeys()
{
if (primaryKeys != null)
Expand Down Expand Up @@ -381,6 +382,11 @@ public static List<PostgreSQLTable> getTables()
}


/**
* Standard toString method.
*
* @return JSON style description of variables.
*/
@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,13 @@ public List<RelationshipMapper> retrieveRelationships(QueryBuilder queryBuilder,
{
final String methodName = "retrieveRelationships";

String sqQuery = queryBuilder.getPropertyJoinQuery(RepositoryTable.RELATIONSHIP.getTableName(),
RepositoryTable.RELATIONSHIP_ATTRIBUTE_VALUE.getTableName(),
"*") +
" where " + queryBuilder.getAsOfTimeWhereClause();
try
{
List<Map<String, JDBCDataValue>> relationshipRows = jdbcResourceConnector.getMatchingRows(RepositoryTable.RELATIONSHIP.getTableName(),
queryBuilder.getAsOfTimeWhereClause() + queryBuilder.getSequenceAndPaging(RepositoryTable.RELATIONSHIP.getTableName()),
List<Map<String, JDBCDataValue>> relationshipRows = jdbcResourceConnector.getMatchingRows(sqQuery + queryBuilder.getSequenceAndPaging(RepositoryTable.RELATIONSHIP.getTableName()),
RepositoryTable.RELATIONSHIP.getColumnNameTypeMap());

if (relationshipRows != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ public static List<PostgreSQLTable> getTables()
}


/**
* Standard toString method.
*
* @return JSON style description of variables.
*/
@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,27 @@ public void setViewServiceAdminClassName(String viewServiceAdminClassName)
{
this.viewServiceAdminClassName = viewServiceAdminClassName;
}


/**
* Standard toString method.
*
* @return JSON style description of variables.
*/
@Override
public String toString()
{
return "ViewServiceRegistrationEntry{" +
"viewServiceCode=" + viewServiceCode +
", viewServiceDevelopmentStatus=" + viewServiceDevelopmentStatus +
", viewServiceName='" + viewServiceName + '\'' +
", viewServiceFullName='" + viewServiceFullName + '\'' +
", viewServiceURLMarker='" + viewServiceURLMarker + '\'' +
", viewServiceDescription='" + viewServiceDescription + '\'' +
", viewServiceWiki='" + viewServiceWiki + '\'' +
", viewServicePartnerService='" + viewServicePartnerService + '\'' +
", viewServiceOperationalStatus=" + viewServiceOperationalStatus +
", viewServiceAdminClassName='" + viewServiceAdminClassName + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9301,6 +9301,7 @@ public B getBeanFromRepository(String userId,
forLineage,
forDuplicateProcessing,
serviceSupportedZones,
asOfTime,
effectiveTime,
methodName);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */

package org.odpi.openmetadata.frameworkservices.gaf.rest;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.odpi.openmetadata.commonservices.ffdc.rest.FFDCResponseBase;
import org.odpi.openmetadata.frameworks.governanceaction.properties.OpenMetadataElementGraph;
import org.odpi.openmetadata.frameworks.openmetadata.metadataelements.AssetGraph;

import java.util.Objects;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;


/**
* OpenMetadataGraphResponse is the response structure used on the Governance Action Framework REST API calls
* that returns an OpenMetadataElementGraph object as a response.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class OpenMetadataGraphResponse extends FFDCResponseBase
{
private OpenMetadataElementGraph elementGraph = null;

/**
* Default constructor
*/
public OpenMetadataGraphResponse()
{
super();
}


/**
* Copy/clone constructor
*
* @param template object to copy
*/
public OpenMetadataGraphResponse(OpenMetadataGraphResponse template)
{
super(template);

if (template != null)
{
this.elementGraph = template.getElementGraph();
}
}


/**
* Return the graph object.
*
* @return graph object
*/
public OpenMetadataElementGraph getElementGraph()
{
return elementGraph;
}


/**
* Set up the graph object.
*
* @param elementGraph - graph object
*/
public void setElementGraph(OpenMetadataElementGraph elementGraph)
{
this.elementGraph = elementGraph;
}


/**
* JSON-style toString
*
* @return return string containing the property names and values
*/
@Override
public String toString()
{
return "OpenMetadataGraphResponse{" +
"elementGraph=" + elementGraph +
"} " + super.toString();
}


/**
* Return comparison result based on the content of the properties.
*
* @param objectToCompare test object
* @return result of comparison
*/
@Override
public boolean equals(Object objectToCompare)
{
if (this == objectToCompare)
{
return true;
}
if (!(objectToCompare instanceof OpenMetadataGraphResponse that))
{
return false;
}
if (!super.equals(objectToCompare))
{
return false;
}
return Objects.equals(getElementGraph(), that.getElementGraph());
}


/**
* Return hash code for this object
*
* @return int hash code
*/
@Override
public int hashCode()
{
if (elementGraph == null)
{
return super.hashCode();
}
else
{
return elementGraph.hashCode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,62 @@ public List<RelatedMetadataElement> getRelatedMetadataElements(String
}


/**
* Return all the elements that are anchored to an asset plus relationships between these elements and to other elements.
*
* @param userId name of the server instances for this request
* @param elementGUID unique identifier for the element
* @param forLineage the retrieved element is for lineage processing so include archived elements
* @param forDuplicateProcessing the retrieved elements are for duplicate processing so do not combine results from known duplicates.
* @param startFrom starting element (used in paging through large result sets)
* @param pageSize maximum number of results to return
* @param asOfTime Requests a historical query of the entity. Null means return the present values.
* @param effectiveTime only return the element if it is effective at this time. Null means anytime. Use "new Date()" for now.
*
* @return graph of elements
*
* @throws InvalidParameterException the unique identifier is null or not known; the relationship type is invalid
* @throws UserNotAuthorizedException the userId is not permitted to perform this operation
* @throws PropertyServerException there is a problem accessing the metadata store
*/
@Override
public OpenMetadataElementGraph getAnchoredElementsGraph(String userId,
String elementGUID,
boolean forLineage,
boolean forDuplicateProcessing,
int startFrom,
int pageSize,
Date asOfTime,
Date effectiveTime) throws InvalidParameterException,
UserNotAuthorizedException,
PropertyServerException
{
final String methodName = "getAnchoredElementsGraph";
final String guidParameterName = "elementGUID";
final String urlTemplate = serverPlatformURLRoot + "/servers/{0}/open-metadata/framework-services/{1}/open-metadata-store/users/{2}/metadata-elements/{3}/with-anchored-elements?forLineage={4}&forDuplicateProcessing={5}&startFrom={6}&pageSize={7}";

invalidParameterHandler.validateUserId(userId, methodName);
invalidParameterHandler.validateGUID(elementGUID, guidParameterName, methodName);

AnyTimeRequestBody requestBody = new AnyTimeRequestBody();
requestBody.setAsOfTime(asOfTime);
requestBody.setEffectiveTime(effectiveTime);
OpenMetadataGraphResponse restResult = restClient.callOpenMetadataGraphPostRESTCall(methodName,
urlTemplate,
requestBody,
serverName,
serviceURLMarker,
userId,
elementGUID,
forLineage,
forDuplicateProcessing,
startFrom,
pageSize);

return restResult.getElementGraph();
}


/**
* Retrieve the metadata element connected to the supplied element for a relationship type that only allows one
* relationship to be attached.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,39 @@ public OpenMetadataElementResponse callOpenMetadataElementPostRESTCall(String
}



/**
* Issue a POST REST call that returns a OpenMetadataGraphResponse object.
*
* @param methodName name of the method being called.
* @param urlTemplate template of the URL for the REST API call, with place-holders for the parameters.
* @param requestBody object that passes additional parameters
* @param params a list of parameters that are slotted into the url template.
*
* @return response object
* @throws InvalidParameterException one of the parameters is invalid.
* @throws UserNotAuthorizedException the user is not authorized to make this request.
* @throws PropertyServerException the repository is not available or not working properly.
*/
public OpenMetadataGraphResponse callOpenMetadataGraphPostRESTCall(String methodName,
String urlTemplate,
Object requestBody,
Object... params) throws InvalidParameterException,
UserNotAuthorizedException,
PropertyServerException
{
OpenMetadataGraphResponse restResult = this.callPostRESTCall(methodName,
OpenMetadataGraphResponse.class,
urlTemplate,
requestBody,
params);

exceptionHandler.detectAndThrowStandardExceptions(methodName, restResult);

return restResult;
}


/**
* Issue a GET REST call that returns a OpenMetadataElementResponse object.
*
Expand Down
Loading

0 comments on commit 0c09057

Please sign in to comment.