Skip to content

Commit

Permalink
Merge pull request #6811 from alexandra-bucur/al-ac-effectivity-dates
Browse files Browse the repository at this point in the history
AC, AL - Change effectivity dates to now
  • Loading branch information
Alexandra Bucur authored Sep 26, 2022
2 parents 7fa09aa + 1c29a33 commit a21908d
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.odpi.openmetadata.accessservices.assetcatalog.handlers.AssetCatalogHandler;
import org.odpi.openmetadata.accessservices.assetcatalog.handlers.RelationshipHandler;
import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean;
import org.odpi.openmetadata.accessservices.assetcatalog.service.ClockService;
import org.odpi.openmetadata.adminservices.configuration.registration.AccessServiceDescription;
import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericHandler;
import org.odpi.openmetadata.commonservices.multitenant.OMASServiceInstance;
Expand All @@ -17,6 +18,7 @@
import org.odpi.openmetadata.frameworks.connectors.properties.beans.Connection;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryConnector;

import java.time.Clock;
import java.util.List;

/**
Expand Down Expand Up @@ -79,13 +81,14 @@ class AssetCatalogServicesInstance extends OMASServiceInstance {
AssetCatalogBean.class, serviceName, serverName, invalidParameterHandler, repositoryHandler,
repositoryHelper, localServerUserId, securityVerifier, supportedZones, defaultZones, publishZones,
auditLog);
ClockService clockService = new ClockService(Clock.systemUTC());

assetCatalogHandler = new AssetCatalogHandler(serverName, sourceName, invalidParameterHandler,
repositoryHandler, repositoryHelper, assetHandler, assetCatalogConverter, errorHandler,
supportedZones, supportedTypesForSearch);
supportedZones, supportedTypesForSearch, clockService);

relationshipHandler = new RelationshipHandler(sourceName, invalidParameterHandler, repositoryHandler,
repositoryHelper, assetHandler, errorHandler);
repositoryHelper, assetHandler, errorHandler, clockService);
} else {
final String methodName = "new ServiceInstance";
throw new NewInstanceException(AssetCatalogErrorCode.OMRS_NOT_INITIALIZED.getMessageDefinition(serverName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.odpi.openmetadata.accessservices.assetcatalog.model.Elements;
import org.odpi.openmetadata.accessservices.assetcatalog.model.Type;
import org.odpi.openmetadata.accessservices.assetcatalog.model.rest.body.SearchParameters;
import org.odpi.openmetadata.accessservices.assetcatalog.service.ClockService;
import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler;
import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericHandler;
import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryErrorHandler;
Expand Down Expand Up @@ -43,7 +44,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -153,6 +153,7 @@ public class AssetCatalogHandler {
private final AssetCatalogConverter<AssetCatalogBean> assetCatalogConverter;
private final OpenMetadataAPIGenericHandler<AssetCatalogBean> assetHandler;
private final Map<String, String> defaultSearchTypes = new HashMap<>();
private final ClockService clockService;
private List<String> supportedTypesForSearch = new ArrayList<>(Arrays.asList(GLOSSARY_TERM, ASSET, SCHEMA_ELEMENT));

private final List<String> supportedZones;
Expand All @@ -170,11 +171,14 @@ public class AssetCatalogHandler {
* @param errorHandler provides common validation routines for the other handler classes
* @param supportedZones configurable list of zones that Asset Catalog is allowed to serve Assets from
* @param supportedTypesForSearch configurable list of supported types used for search
* @param clockService clock service
*/
public AssetCatalogHandler(String serverUserName, String sourceName, InvalidParameterHandler invalidParameterHandler,
RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
OpenMetadataAPIGenericHandler<AssetCatalogBean> assetHandler, AssetCatalogConverter<AssetCatalogBean> assetCatalogConverter,
RepositoryErrorHandler errorHandler, List<String> supportedZones, List<String> supportedTypesForSearch) {
OpenMetadataAPIGenericHandler<AssetCatalogBean> assetHandler,
AssetCatalogConverter<AssetCatalogBean> assetCatalogConverter,
RepositoryErrorHandler errorHandler, List<String> supportedZones, List<String> supportedTypesForSearch,
ClockService clockService) {
this.serverUserName = serverUserName;
this.sourceName = sourceName;
this.invalidParameterHandler = invalidParameterHandler;
Expand All @@ -184,11 +188,13 @@ public AssetCatalogHandler(String serverUserName, String sourceName, InvalidPara
this.assetCatalogConverter = assetCatalogConverter;
this.errorHandler = errorHandler;
this.supportedZones = supportedZones;
this.commonHandler = new CommonHandler(sourceName, repositoryHandler, repositoryHelper, assetHandler, errorHandler);
this.commonHandler = new CommonHandler(sourceName, repositoryHandler, repositoryHelper, assetHandler, errorHandler,
clockService);
if (CollectionUtils.isNotEmpty(supportedTypesForSearch)) {
this.supportedTypesForSearch = supportedTypesForSearch;
Collections.sort(supportedTypesForSearch);
}
this.clockService = clockService;
defaultSearchTypes.put(GLOSSARY_TERM, GLOSSARY_TERM_TYPE_GUID);
defaultSearchTypes.put(ASSET, ASSET_GUID);
defaultSearchTypes.put(SCHEMA_ELEMENT, SCHEMA_ELEMENT_GUID);
Expand Down Expand Up @@ -238,8 +244,9 @@ public List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship
invalidParameterHandler.validateGUID(assetGUID, GUID_PARAMETER, methodName);

List<Relationship> relationshipsByType = assetHandler.getAttachmentLinks(userId, assetGUID, GUID_PARAMETER,
assetTypeName, null, null, null, null, 0,
false, false, 0, invalidParameterHandler.getMaxPagingSize(), null, methodName);
assetTypeName, null, null, null,
null, 0, false, false, 0,
invalidParameterHandler.getMaxPagingSize(), clockService.getNow(), methodName);

if (CollectionUtils.isNotEmpty(relationshipsByType)) {
return assetCatalogConverter.convertRelationships(relationshipsByType);
Expand Down Expand Up @@ -312,7 +319,7 @@ public List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship

List<Relationship> pagedRelationshipsByType = assetHandler.getAttachmentLinks(userId, assetGUID, GUID_PARAMETER,
assetTypeName, relationshipTypeGUID, relationshipTypeName, null, null,0,
false, false, from, pageSize, null, methodName);
false, false, from, pageSize, clockService.getNow(), methodName);

if (CollectionUtils.isNotEmpty(pagedRelationshipsByType)) {
return assetCatalogConverter.convertRelationships(pagedRelationshipsByType);
Expand Down Expand Up @@ -770,7 +777,7 @@ private void getContextForProcess(String userId,
if (port.getType().getTypeDefName().equals(PORT_IMPLEMENTATION)) {
EntityDetail schemaType = assetHandler.getAttachedEntity(userId, port.getGUID(), GUID_PARAMETER,
DATABASE, PORT_SCHEMA_GUID, PORT_SCHEMA, null, false,
false, new Date(), method);
false, clockService.getNow(), method);

if (schemaType != null) {
assetCatalogConverter.addElement(assetCatalogItemElement, schemaType);
Expand Down Expand Up @@ -824,7 +831,7 @@ private void getContextForDataSet(String userId,

EntityDetail schemaType = assetHandler.getAttachedEntity(userId, dataSet.getGUID(), GUID_PARAMETER,
DATA_SET, ASSET_SCHEMA_TYPE_GUID, ASSET_SCHEMA_TYPE, null, false,
false, new Date(), method);
false, clockService.getNow(), method);

if (schemaType == null) {
return;
Expand Down Expand Up @@ -859,7 +866,7 @@ private void getContextForFileFolder(String userId,
List<Relationship> parentFolderRelationships = assetHandler.getAttachmentLinks(userId, entityDetail.getGUID(),
GUID_PARAMETER, entityDetail.getType().getTypeDefName(), FOLDER_HIERARCHY_GUID,
FOLDER_HIERARCHY, null, null,0, false, false,
0, invalidParameterHandler.getMaxPagingSize(), new Date(), method);
0, invalidParameterHandler.getMaxPagingSize(), clockService.getNow(), method);

if (CollectionUtils.isEmpty(parentFolderRelationships)) {
return;
Expand Down Expand Up @@ -919,7 +926,7 @@ private void getContextForSoftwareServerPlatform(String userId,
EntityDetail host = assetHandler.getAttachedEntity(userId, entityDetail.getGUID(), GUID_PARAMETER,
entityDetail.getType().getTypeDefName(), SOFTWARE_SERVER_PLATFORM_DEPLOYMENT_GUID,
SOFTWARE_SERVER_PLATFORM_DEPLOYMENT, null, false, false,
new Date(), method);
clockService.getNow(), method);
if (host != null) {
assetCatalogConverter.addElement(assetCatalogItemElement, host);
getContextForHost(userId, host, assetCatalogItemElement);
Expand Down Expand Up @@ -977,7 +984,7 @@ private void getContextForHost(String userId,

EntityDetail operatingPlatform = assetHandler.getAttachedEntity(userId, entityDetail.getGUID(), GUID_PARAMETER,
entityDetail.getType().getTypeDefName(), HOST_OPERATING_PLATFORM_GUID, HOST_OPERATING_PLATFORM,
null, false, false, new Date(), method);
null, false, false, clockService.getNow(), method);
assetCatalogConverter.addElement(assetCatalogItemElement, operatingPlatform);

processLocations(userId, entityDetail, assetCatalogItemElement, method);
Expand Down Expand Up @@ -1027,7 +1034,7 @@ private void getContextForSoftwareServer(String userId,

EntityDetail softwareServerPlatform = assetHandler.getAttachedEntity(userId, entityDetail.getGUID(),
GUID_PARAMETER, SOFTWARE_SERVER, SOFTWARE_SERVER_DEPLOYMENT_GUID, SOFTWARE_SERVER_DEPLOYMENT,
null, false, false, new Date(), method);
null, false, false, clockService.getNow(), method);
if (softwareServerPlatform != null) {
parentElement = assetCatalogConverter.getLastNode(assetCatalogItemElement);
assetCatalogConverter.addElement(assetCatalogItemElement, softwareServerPlatform);
Expand All @@ -1036,7 +1043,7 @@ private void getContextForSoftwareServer(String userId,

EntityDetail endpoint = assetHandler.getAttachedEntity(userId, entityDetail.getGUID(),
GUID_PARAMETER, SOFTWARE_SERVER, SERVER_ENDPOINT_GUID, SERVER_ENDPOINT,
null, false, false, new Date(), method);
null, false, false, clockService.getNow(), method);
if (endpoint != null) {
if (parentElement != null) {
assetCatalogConverter.addChildElement(parentElement, assetCatalogConverter.buildAssetElements(endpoint));
Expand Down Expand Up @@ -1068,14 +1075,14 @@ private void getConnectionContext(String userId,
List<EntityDetail> elements = new ArrayList<>();
EntityDetail connectorType = assetHandler.getAttachedEntity(userId, connection.getGUID(),
GUID_PARAMETER, CONNECTION, CONNECTION_CONNECTOR_TYPE_GUID, CONNECTION_CONNECTOR_TYPE,
null, false, false, new Date(), methodName);
null, false, false, clockService.getNow(), methodName);
if (connectorType != null) {
elements.add(connectorType);
}

EntityDetail asset = assetHandler.getAttachedEntity(userId, connection.getGUID(),
GUID_PARAMETER, CONNECTION, CONNECTION_TO_ASSET_GUID, CONNECTION_TO_ASSET,
null, false, false, new Date(), methodName);
null, false, false, clockService.getNow(), methodName);
invalidParameterHandler.validateAssetInSupportedZone(asset.getGUID(),
GUID_PARAMETER,
commonHandler.getAssetZoneMembership(asset.getClassifications()),
Expand Down Expand Up @@ -1201,7 +1208,7 @@ private void setAssetDetails(String userId,

EntityDetail dataSet = assetHandler.getAttachedEntity(userId, entity.getGUID(),
GUID_PARAMETER, entity.getType().getTypeDefName(), ASSET_SCHEMA_TYPE_GUID, ASSET_SCHEMA_TYPE,
null, false, false, new Date(), methodName);
null, false, false, clockService.getNow(), methodName);
if (dataSet == null) {
return;
}
Expand Down Expand Up @@ -1238,8 +1245,8 @@ private void getAsset(String userId,
String methodName = "getAsset";
List<Relationship> assetToDataSetRelationships = assetHandler.getAttachmentLinks(userId, dataSet.getGUID(),
GUID_PARAMETER, dataSet.getType().getTypeDefName(), DATA_CONTENT_FOR_DATA_SET_GUID,
DATA_CONTENT_FOR_DATA_SET, null, null, 1, false, false,0,
invalidParameterHandler.getMaxPagingSize(), new Date(), methodName);
DATA_CONTENT_FOR_DATA_SET, null, null, 1, false,
false,0, invalidParameterHandler.getMaxPagingSize(), clockService.getNow(), methodName);

if (CollectionUtils.isEmpty(assetToDataSetRelationships)) {
return;
Expand Down Expand Up @@ -1345,7 +1352,7 @@ private List<EntityDetail> searchEntityByCriteria(String userId,
SEARCH_STRING_PARAMETER_NAME, entityTypeGUID, entityTypeName, Collections.singletonList(propertyName),
searchParameters.getExactMatch(), null, null, false,
false, supportedZones, sequencingOrder.getName(),searchParameters.getFrom(),
searchParameters.getPageSize(), null, methodName);
searchParameters.getPageSize(), clockService.getNow(), methodName);

if (CollectionUtils.isNotEmpty(entitiesByPropertyValue)) {
return entitiesByPropertyValue;
Expand All @@ -1361,7 +1368,7 @@ private List<EntityDetail> searchEntityByType(String userId,

List<EntityDetail> entitiesByPropertyValue = assetHandler.getEntitiesByType(userId, entityTypeGUID,
entityTypeName, null,false,false, 0,
20, new Date(), methodName);
20, clockService.getNow(), methodName);

if (CollectionUtils.isNotEmpty(entitiesByPropertyValue)) {
return entitiesByPropertyValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.odpi.openmetadata.accessservices.assetcatalog.converters.AssetCatalogConverter;
import org.odpi.openmetadata.accessservices.assetcatalog.model.AssetCatalogBean;
import org.odpi.openmetadata.accessservices.assetcatalog.model.Type;
import org.odpi.openmetadata.accessservices.assetcatalog.service.ClockService;
import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericHandler;
import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryErrorHandler;
import org.odpi.openmetadata.commonservices.repositoryhandler.RepositoryHandler;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class CommonHandler {
private final OMRSRepositoryHelper repositoryHelper;
private final OpenMetadataAPIGenericHandler<AssetCatalogBean> assetHandler;
private final RepositoryErrorHandler errorHandler;
private final ClockService clockService;

/**
* Construct the handler information needed to interact with the repository services
Expand All @@ -63,12 +65,14 @@ public class CommonHandler {
* @param errorHandler provides common validation routines for the other handler classes
*/
CommonHandler(String sourceName, RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
OpenMetadataAPIGenericHandler<AssetCatalogBean> assetHandler, RepositoryErrorHandler errorHandler) {
OpenMetadataAPIGenericHandler<AssetCatalogBean> assetHandler, RepositoryErrorHandler errorHandler,
ClockService clockService) {
this.sourceName = sourceName;
this.repositoryHandler = repositoryHandler;
this.repositoryHelper = repositoryHelper;
this.assetHandler = assetHandler;
this.errorHandler = errorHandler;
this.clockService = clockService;
}

OMRSMetadataCollection getOMRSMetadataCollection() {
Expand Down Expand Up @@ -205,7 +209,7 @@ EntityDetail getEntityByGUID(String userId,
String methodName = "getEntityByGUID";
return assetHandler.getEntityFromRepository(userId, guid, GUID_PARAMETER, entityTypeName,
null, null, false, false,
null, methodName);
clockService.getNow(), methodName);
}

/**
Expand Down
Loading

0 comments on commit a21908d

Please sign in to comment.