Skip to content

Commit

Permalink
Merge pull request #6802 from alexandra-bucur/de-effectivity-dates
Browse files Browse the repository at this point in the history
Data Engine - Change effective time to now
  • Loading branch information
Alexandra Bucur authored Sep 26, 2022
2 parents 9a8b945 + d594d2d commit 7fa09aa
Show file tree
Hide file tree
Showing 19 changed files with 154 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.odpi.openmetadata.accessservices.dataengine.server.handlers.DataEngineSchemaAttributeHandler;
import org.odpi.openmetadata.accessservices.dataengine.server.handlers.DataEngineSchemaTypeHandler;
import org.odpi.openmetadata.accessservices.dataengine.server.handlers.DataEngineTopicHandler;
import org.odpi.openmetadata.accessservices.dataengine.server.service.ClockService;
import org.odpi.openmetadata.adminservices.configuration.registration.AccessServiceDescription;
import org.odpi.openmetadata.commonservices.generichandlers.AssetHandler;
import org.odpi.openmetadata.commonservices.generichandlers.ConnectionHandler;
Expand All @@ -71,6 +72,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 @@ -310,11 +312,12 @@ public class DataEngineServicesInstance extends OMASServiceInstance {
Referenceable.class, serviceName, serverName, invalidParameterHandler, repositoryHandler,
repositoryHelper, localServerUserId, securityVerifier, supportedZones, defaultZones, publishZones, auditLog);

ClockService clockService = new ClockService(Clock.systemUTC());
dataEngineRegistrationHandler = new DataEngineRegistrationHandler(serviceName, serverName, invalidParameterHandler,
repositoryHelper, softwareServerCapabilityHandler);
repositoryHelper, softwareServerCapabilityHandler, clockService);

dataEngineCommonHandler = new DataEngineCommonHandler(serviceName, serverName, invalidParameterHandler,
referenceableHandler, repositoryHelper, dataEngineRegistrationHandler);
referenceableHandler, repositoryHelper, dataEngineRegistrationHandler, clockService);

final ConnectionHandler<org.odpi.openmetadata.accessservices.dataengine.model.Connection> connectionHandler =
new ConnectionHandler<>(new ConnectionConverter<>(repositoryHelper, serviceName, serverName),
Expand Down Expand Up @@ -366,7 +369,7 @@ public class DataEngineServicesInstance extends OMASServiceInstance {
dataEngineConnectionAndEndpointHandler);

dataEngineFindHandler = new DataEngineFindHandler(invalidParameterHandler, repositoryHelper, referenceableHandler,
serviceName, serverName);
dataEngineCommonHandler, serviceName, serverName);

dataEngineTopicHandler = new DataEngineTopicHandler(invalidParameterHandler, topicHandler,
dataEngineRegistrationHandler, dataEngineCommonHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public String createCollection(String userId, Collection collection, String exte

CollectionBuilder builder = getCollectionBuilder(collection);

return collectionOpenMetadataAPIGenericHandler.createBeanInRepository(userId, externalSourceGUID, externalSourceName, COLLECTION_TYPE_GUID,
COLLECTION_TYPE_NAME, builder, null, methodName);
return collectionOpenMetadataAPIGenericHandler.createBeanInRepository(userId, externalSourceGUID, externalSourceName,
COLLECTION_TYPE_GUID, COLLECTION_TYPE_NAME, builder, dataEngineCommonHandler.getNow(), methodName);
}

CollectionBuilder getCollectionBuilder(Collection collection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.odpi.openmetadata.accessservices.dataengine.model.OwnerType;
import org.odpi.openmetadata.accessservices.dataengine.model.Referenceable;
import org.odpi.openmetadata.accessservices.dataengine.server.mappers.CommonMapper;
import org.odpi.openmetadata.accessservices.dataengine.server.service.ClockService;
import org.odpi.openmetadata.commonservices.ffdc.InvalidParameterHandler;
import org.odpi.openmetadata.commonservices.generichandlers.OpenMetadataAPIGenericHandler;
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
Expand All @@ -29,6 +30,7 @@

import java.util.Date;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
Expand All @@ -48,6 +50,7 @@ public class DataEngineCommonHandler {
private final OMRSRepositoryHelper repositoryHelper;
private final InvalidParameterHandler invalidParameterHandler;
private final DataEngineRegistrationHandler dataEngineRegistrationHandler;
private final ClockService clockService;

private static final Logger log = LoggerFactory.getLogger(DataEngineCommonHandler.class);

Expand All @@ -63,13 +66,14 @@ public class DataEngineCommonHandler {
*/
public DataEngineCommonHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler,
OpenMetadataAPIGenericHandler<Referenceable> genericHandler, OMRSRepositoryHelper repositoryHelper,
DataEngineRegistrationHandler dataEngineRegistrationHandler) {
DataEngineRegistrationHandler dataEngineRegistrationHandler, ClockService clockService) {
this.serviceName = serviceName;
this.serverName = serverName;
this.invalidParameterHandler = invalidParameterHandler;
this.genericHandler = genericHandler;
this.repositoryHelper = repositoryHelper;
this.dataEngineRegistrationHandler = dataEngineRegistrationHandler;
this.clockService = clockService;
}

/**
Expand Down Expand Up @@ -131,7 +135,7 @@ public Optional<EntityDetail> findEntity(String userId, String qualifiedName, St

EntityDetail retrievedEntity = genericHandler.getEntityByValue(userId, qualifiedName, CommonMapper.QUALIFIED_NAME_PROPERTY_NAME,
entityTypeDef.getGUID(), entityTypeDef.getName(), Collections.singletonList(CommonMapper.QUALIFIED_NAME_PROPERTY_NAME),
false, false, null, methodName);
false, false, getNow(), methodName);

String guid = null;
if(retrievedEntity != null) {
Expand Down Expand Up @@ -163,7 +167,7 @@ public Optional<EntityDetail> getEntityDetails(String userId, String entityDetai

EntityDetail retrievedEntity = genericHandler.getEntityFromRepository(userId, entityDetailGUID,
CommonMapper.GUID_PROPERTY_NAME, entityTypeName, null, null,
false, false, null, null, methodName);
false, false, null, getNow(), methodName);

return Optional.ofNullable(retrievedEntity);
}
Expand Down Expand Up @@ -208,7 +212,8 @@ protected void upsertExternalRelationship(String userId, String firstGUID, Strin
genericHandler.linkElementToElement(userId, externalSourceGUID, externalSourceName, firstGUID,
CommonMapper.GUID_PROPERTY_NAME, firstEntityTypeName, secondGUID, CommonMapper.GUID_PROPERTY_NAME,
secondEntityTypeName, false, false, null,
relationshipTypeDef.getGUID(), relationshipTypeName, relationshipProperties, null, null, null, methodName);
relationshipTypeDef.getGUID(), relationshipTypeName, relationshipProperties, null,
null, getNow(), methodName);
} else {
Relationship originalRelationship = relationship.get();
String relationshipGUID = originalRelationship.getGUID();
Expand All @@ -219,7 +224,7 @@ protected void upsertExternalRelationship(String userId, String firstGUID, Strin
if (relationshipDifferences.hasInstancePropertiesDifferences()) {
genericHandler.updateRelationshipProperties(userId, externalSourceGUID, externalSourceName, relationshipGUID,
GUID_PROPERTY_NAME, originalRelationship.getType().getTypeDefName(), true,
relationshipProperties, false, false, null, methodName);
relationshipProperties, false, false, getNow(), methodName);
}
}
}
Expand Down Expand Up @@ -255,7 +260,7 @@ protected Optional<Relationship> findRelationship(String userId, String firstGUI
Relationship relationshipBetweenEntities = genericHandler.getUniqueAttachmentLink(userId, firstGUID,
CommonMapper.GUID_PROPERTY_NAME, firstEntityTypeName, relationshipTypeDef.getGUID(),
relationshipTypeDef.getName(), secondGUID, secondEntityTypeName, 0,
false, false, null, methodName);
false, false, getNow(), methodName);

if (relationshipBetweenEntities == null) {
return Optional.empty();
Expand Down Expand Up @@ -293,7 +298,8 @@ protected void removeEntity(String userId, String entityGUID, String entityTypeN
String externalSourceGUID = dataEngineRegistrationHandler.getExternalDataEngine(userId, externalSourceName);

genericHandler.deleteBeanInRepository(userId, externalSourceGUID, externalSourceName, entityGUID, GUID_PROPERTY_NAME,
entityTypeDef.getGUID(), entityTypeDef.getName(), null, null, false, false, null, methodName);
entityTypeDef.getGUID(), entityTypeDef.getName(), null, null,
false, false, getNow(), methodName);
}

/**
Expand Down Expand Up @@ -364,7 +370,8 @@ protected Set<EntityDetail> getEntitiesForRelationship(String userId, String gui

List<EntityDetail> entities = genericHandler.getAttachedEntities(userId, guid, CommonMapper.GUID_PROPERTY_NAME,
entityTypeName, relationshipTypeDef.getGUID(), relationshipTypeName, resultingElementTypeName,
null, null, 0, false, false, 0, invalidParameterHandler.getMaxPagingSize(), null, methodName);
null, null, 0, false,
false, 0, invalidParameterHandler.getMaxPagingSize(), getNow(), methodName);

if (CollectionUtils.isEmpty(entities)) {
return new HashSet<>();
Expand Down Expand Up @@ -399,7 +406,7 @@ protected Optional<EntityDetail> getEntityForRelationship(String userId, String
TypeDef relationshipTypeDef = repositoryHelper.getTypeDefByName(userId, relationshipTypeName);
EntityDetail entity = genericHandler.getAttachedEntity(userId, entityGUID, GUID_PROPERTY_NAME,
entityTypeName, relationshipTypeDef.getGUID(), relationshipTypeDef.getName(), null,
false, false, null, methodName);
false, false, getNow(), methodName);
return Optional.ofNullable(entity);
}

Expand All @@ -409,4 +416,8 @@ protected void validateDeleteSemantic(DeleteSemantic deleteSemantic, String meth
serverName), this.getClass().getName(), methodName);
}
}

protected Date getNow() {
return clockService.getNow();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,27 @@ private void createConnectionAndRelatedEntities(String assetQualifiedName, Strin

String connectorProviderClassName = connectorType.getClass().getSimpleName();
String connectorTypeQualifiedName = getConnectorTypeQualifiedName(assetTypeName, assetQualifiedName);
Date now = dataEngineCommonHandler.getNow();
String connectorTypeGUID = connectorTypeHandler.getConnectorTypeForConnection(userID, externalSourceGUID,
externalSourceName, null, connectorTypeQualifiedName, connectorTypeQualifiedName,
null, assetTypeName, null, connectorProviderClassName,
OpenMetadataAPIMapper.CONNECTOR_FRAMEWORK_NAME_DEFAULT, OpenMetadataAPIMapper.CONNECTOR_INTERFACE_LANGUAGE_DEFAULT,
null, null, null, null,
null, null, null, null,
null,false, false, null, methodName);
null,false, false, now, methodName);

String endpointQualifiedName = getEndpointQualifiedName(assetTypeName, assetQualifiedName);
String endpointGUID = endpointHandler.createEndpoint(userID, externalSourceGUID, externalSourceName, null,
endpointQualifiedName, endpointQualifiedName, ACCESS_INFORMATION + networkAddress, networkAddress,
protocol, null, null, null, null, null,
null, null, methodName);
null, now, methodName);

String connectionGUID = connectionHandler.createConnection(userID, externalSourceGUID, externalSourceName, assetGUID, ASSET_GUID,
null, connectionQualifiedName, connectionQualifiedName, null, null,
null, null, null, null, null,
OpenMetadataAPIMapper.CONNECTION_TYPE_NAME, null, connectorTypeGUID, CONNECTOR_TYPE_GUID_PARAMETER_NAME,
endpointGUID, ENDPOINT_GUID_PARAMETER_NAME, null, null,false, false, null, methodName);
endpointGUID, ENDPOINT_GUID_PARAMETER_NAME, null, null,false,
false, now, methodName);

log.debug(CONNECTION_CREATED, assetQualifiedName, connectionQualifiedName, connectionGUID, endpointGUID, connectorTypeGUID);
}
Expand All @@ -196,7 +198,8 @@ private Optional<ConnectorType> getProperConnectorType(String assetTypeName, Str
final String methodName = "getProperConnectorType";

List<ConnectorType> connectorTypes = connectorTypeHandler.findConnectorTypes(userId, assetTypeName,
SEARCH_STRING_PARAMETER_NAME, START_FROM, PAGE_SIZE, false, false, null, methodName);
SEARCH_STRING_PARAMETER_NAME, START_FROM, PAGE_SIZE, false, false, dataEngineCommonHandler.getNow(),
methodName);
if(CollectionUtils.isEmpty(connectorTypes)) {
return Optional.empty();
}
Expand Down Expand Up @@ -227,7 +230,7 @@ public void removeConnection(String userId, String connectionGUID, DeleteSemanti
invalidParameterHandler.validateGUID(connectionGUID, GUID_PROPERTY_NAME, methodName);

connectionHandler.removeConnection(userId, externalSourceGUID, externalSourceName, connectionGUID,
CONNECTION_GUID_PARAMETER_NAME, false, false, null, methodName);
CONNECTION_GUID_PARAMETER_NAME, false, false, dataEngineCommonHandler.getNow(), methodName);
}

/**
Expand All @@ -253,7 +256,7 @@ public void removeEndpoint(String userId, String endpointGUID, DeleteSemantic de
invalidParameterHandler.validateGUID(endpointGUID, GUID_PROPERTY_NAME, methodName);

endpointHandler.removeEndpoint(userId, externalSourceGUID, externalSourceName, endpointGUID,
ENDPOINT_GUID_PARAMETER_NAME, false, false, null, methodName);
ENDPOINT_GUID_PARAMETER_NAME, false, false, dataEngineCommonHandler.getNow(), methodName);
}

private void updateEndpoint(String protocol, String networkAddress, String assetTypeName, String assetQualifiedName,
Expand All @@ -276,7 +279,7 @@ private void updateEndpoint(String protocol, String networkAddress, String asset
endpointQualifiedName, endpointQualifiedName, description, networkAddress,
protocol, null, null, null,
null, true, null, null, false,
false, null, methodName);
false, dataEngineCommonHandler.getNow(), methodName);

log.debug(ENDPOINT_UPDATED, assetQualifiedName, endpointQualifiedName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper;
import org.odpi.openmetadata.repositoryservices.ffdc.exception.FunctionNotSupportedException;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -121,7 +119,7 @@ public String upsertFileAssetIntoCatalog(String fileTypeName, String fileTypeGui
if (file.getIncomplete()) {
fileHandler.setClassificationInRepository(userId, externalSourceGuid, externalSourceName, fileGuid, FILE_GUID_PARAMETER_NAME, fileTypeName,
INCOMPLETE_CLASSIFICATION_TYPE_GUID, INCOMPLETE_CLASSIFICATION_TYPE_NAME, null,
true, false, false, null, methodName);
true, false, false, dataEngineCommonHandler.getNow(), methodName);
}

return fileGuid;
Expand Down Expand Up @@ -153,7 +151,8 @@ public void removeDataFile(String userId, String dataFileGUID, String externalSo
dataEngineSchemaTypeHandler.removeSchemaType(userId, schemaType.get().getGUID(), externalSourceName, deleteSemantic);

fileHandler.deleteBeanInRepository(userId, externalSourceGUID, externalSourceName, dataFileGUID, GUID_PROPERTY_NAME,
DATA_FILE_TYPE_GUID, DATA_FILE_TYPE_NAME, null, null, false, false, null, methodName);
DATA_FILE_TYPE_GUID, DATA_FILE_TYPE_NAME, null, null, false,
false, dataEngineCommonHandler.getNow(), methodName);
} else {
dataEngineCommonHandler.throwInvalidParameterException(DataEngineErrorCode.ENTITY_NOT_DELETED, methodName, dataFileGUID);
}
Expand All @@ -169,7 +168,7 @@ private String updateFileInRepository(String userId, String externalSourceGuid,
CommonMapper.GUID_PROPERTY_NAME, file.getQualifiedName(), file.getDisplayName(),
file.getDescription(), file.getAdditionalProperties(), entityTypeDef.getGUID(),
entityTypeDef.getName(), extendedProperties, null, null, true,
false, false, null, methodName);
false, false, dataEngineCommonHandler.getNow(), methodName);
return fileAsEntity.getGUID();
}

Expand All @@ -183,8 +182,8 @@ private String createFileInRepository(String typeName, String typeGuid, DataFile
file.getQualifiedName(), file.getDisplayName(), file.getDescription(), file.getZoneMembership(),
file.getOwner(), ownerType, file.getOriginOrganizationGUID(),
file.getOriginBusinessCapabilityGUID(), file.getOtherOriginValues(), file.getAdditionalProperties(),
typeGuid, typeName, extendedProperties, null,
null, InstanceStatus.ACTIVE, null, methodName);
typeGuid, typeName, extendedProperties, null, null, InstanceStatus.ACTIVE,
dataEngineCommonHandler.getNow(), methodName);
}

private void validateParameters(DataFile file, SchemaType schemaType, String externalSourceGuid, String userId, String methodName) throws
Expand Down
Loading

0 comments on commit 7fa09aa

Please sign in to comment.