Skip to content

Commit f5c4d8d

Browse files
Merge pull request #8903 from mandy-chessell/oak2025
Refresh configuration documents
2 parents 58a4a56 + 19f709a commit f5c4d8d

File tree

25 files changed

+1562
-45
lines changed

25 files changed

+1562
-45
lines changed

open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataCollection.java

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,6 +2839,85 @@ public List<EntityDetail> getEntityDetailHistory(String userId,
28392839
}
28402840

28412841

2842+
/**
2843+
* Return all historical versions of an entity's classification within the bounds of the provided timestamps.
2844+
* To retrieve all historical versions of an entity's classification, set both the 'fromTime' and 'toTime' to null.
2845+
*
2846+
* @param userId unique identifier for requesting user.
2847+
* @param guid String unique identifier for the entity.
2848+
* @param classificationName name of the classification within entity
2849+
* @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive)
2850+
* @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive)
2851+
* @param startFromElement the starting element number of the historical versions to return. This is used when retrieving
2852+
* versions beyond the first page of results. Zero means start from the first element.
2853+
* @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted
2854+
* return results size.
2855+
* @param sequencingOrder Enum defining how the results should be ordered.
2856+
* @return {@code List<Classification>} of each historical version of the entity's classification within the bounds, and in the order requested.
2857+
* @throws InvalidParameterException the guid or date is null or fromTime is after the toTime
2858+
* @throws RepositoryErrorException there is a problem communicating with the metadata repository where the metadata collection is stored.
2859+
* @throws EntityNotKnownException the requested entity instance is not active in the metadata collection at the time requested.
2860+
* @throws EntityProxyOnlyException the requested entity instance is only a proxy in the metadata collection.
2861+
* @throws FunctionNotSupportedException the repository does not support history.
2862+
* @throws UserNotAuthorizedException the userId is not permitted to perform this operation.
2863+
*/
2864+
public List<Classification> getClassificationHistory(String userId,
2865+
String guid,
2866+
String classificationName,
2867+
Date fromTime,
2868+
Date toTime,
2869+
int startFromElement,
2870+
int pageSize,
2871+
HistorySequencingOrder sequencingOrder) throws InvalidParameterException,
2872+
RepositoryErrorException,
2873+
EntityNotKnownException,
2874+
EntityProxyOnlyException,
2875+
FunctionNotSupportedException,
2876+
UserNotAuthorizedException
2877+
{
2878+
final String methodName = "getClassificationHistory";
2879+
2880+
/*
2881+
* Validate parameters
2882+
*/
2883+
this.getInstanceHistoryParameterValidation(userId, classificationName, guid, fromTime, toTime, methodName);
2884+
2885+
/*
2886+
* Perform operation
2887+
*/
2888+
boolean oldestFirst = (sequencingOrder == HistorySequencingOrder.FORWARDS);
2889+
List<Classification> classificationHistory = repositoryStore.getClassificationHistory(guid, classificationName, fromTime, toTime, oldestFirst);
2890+
2891+
if (classificationHistory == null)
2892+
{
2893+
repositoryValidator.validateEntityFromStore(repositoryName, guid, null, methodName);
2894+
}
2895+
else
2896+
{
2897+
if (classificationHistory.isEmpty())
2898+
{
2899+
return null;
2900+
}
2901+
2902+
if (startFromElement > classificationHistory.size())
2903+
{
2904+
return null;
2905+
}
2906+
2907+
if ((pageSize == 0) || (pageSize >= classificationHistory.size()))
2908+
{
2909+
return new ArrayList<>(classificationHistory.subList(startFromElement, classificationHistory.size()));
2910+
}
2911+
else
2912+
{
2913+
return new ArrayList<>(classificationHistory.subList(startFromElement, pageSize));
2914+
}
2915+
}
2916+
2917+
return null;
2918+
}
2919+
2920+
28422921
/**
28432922
* Add a new relationship between two entities to the metadata collection.
28442923
*

open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/inmemory-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/inmemory/repositoryconnector/InMemoryOMRSMetadataStore.java

Lines changed: 183 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
package org.odpi.openmetadata.adapters.repositoryservices.inmemory.repositoryconnector;
44

55

6-
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Classification;
7-
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityDetail;
8-
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntityProxy;
9-
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.EntitySummary;
10-
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceHeader;
11-
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship;
6+
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.*;
127
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper;
138
import org.odpi.openmetadata.repositoryservices.ffdc.exception.RepositoryErrorException;
149
import org.slf4j.Logger;
@@ -31,6 +26,50 @@ class InMemoryOMRSMetadataStore
3126
private static final Logger log = LoggerFactory.getLogger(InMemoryOMRSMetadataStore.class);
3227

3328

29+
/**
30+
* Determine which classifications were active between the from and to date.
31+
*
32+
* @param fromTime starting time
33+
* @param toTime ending time
34+
* @param classifications instance version
35+
* @param versionEndTime time when this version was superseded
36+
* @return boolean flag - true means it is valid
37+
*/
38+
static synchronized List<Classification> getClassificationsForInclusiveDate(String classificationName,
39+
Date fromTime,
40+
Date toTime,
41+
List<Classification> classifications,
42+
Date versionEndTime)
43+
{
44+
if ((classifications != null) && (! classifications.isEmpty()))
45+
{
46+
List<Classification> results = new ArrayList<>();
47+
48+
for (Classification classification : classifications)
49+
{
50+
if ((classification != null) && (classification.getName().equals(classificationName)))
51+
{
52+
if (checkInclusiveDate(fromTime,
53+
toTime,
54+
classification,
55+
versionEndTime))
56+
{
57+
results.add(classification);
58+
}
59+
}
60+
}
61+
62+
if (! results.isEmpty())
63+
{
64+
return results;
65+
}
66+
}
67+
68+
return null;
69+
}
70+
71+
72+
3473
/**
3574
* Determine is an instance was active between the from and to date.
3675
*
@@ -40,10 +79,10 @@ class InMemoryOMRSMetadataStore
4079
* @param versionEndTime time when this version was superseded
4180
* @return boolean flag - true means it is valid
4281
*/
43-
static synchronized boolean checkInclusiveDate(Date fromTime,
44-
Date toTime,
45-
InstanceHeader instanceHeader,
46-
Date versionEndTime)
82+
static synchronized boolean checkInclusiveDate(Date fromTime,
83+
Date toTime,
84+
InstanceAuditHeader instanceHeader,
85+
Date versionEndTime)
4786
{
4887
Date versionStartTime = instanceHeader.getUpdateTime();
4988

@@ -543,6 +582,33 @@ synchronized List<EntityDetail> getEntityHistory(String guid,
543582
}
544583

545584

585+
/**
586+
* Return the versions of the instance that where active between the "from" and "to" times.
587+
*
588+
* @param guid unique identifier of the instance
589+
* @param classificationName name of the classification history to retrieve
590+
* @param fromTime starting time
591+
* @param toTime ending time
592+
* @param oldestFirst ordering
593+
* @return list of instance versions
594+
*/
595+
synchronized List<Classification> getClassificationHistory(String guid,
596+
String classificationName,
597+
Date fromTime,
598+
Date toTime,
599+
boolean oldestFirst)
600+
{
601+
StoredEntity storedEntity = entityStore.get(guid);
602+
603+
if (storedEntity == null)
604+
{
605+
return null;
606+
}
607+
608+
return storedEntity.getClassificationHistory(classificationName, fromTime, toTime, oldestFirst);
609+
}
610+
611+
546612
/**
547613
* Return the versions of the instance that where active between the "from" and "to" times.
548614
*
@@ -1142,6 +1208,112 @@ synchronized List<EntityDetail> getEntityHistory(Date fromTime,
11421208
}
11431209

11441210

1211+
/**
1212+
* Return the instances that match the history.
1213+
*
1214+
* @param classificationName name of the classification history to retrieve
1215+
* @param fromTime starting time
1216+
* @param toTime ending time
1217+
* @param oldestFirst ordering of results
1218+
* @return list of versions of this relationship
1219+
*/
1220+
synchronized List<Classification> getClassificationHistory(String classificationName,
1221+
Date fromTime,
1222+
Date toTime,
1223+
boolean oldestFirst)
1224+
{
1225+
/*
1226+
* Do not have a full entity
1227+
*/
1228+
if (this.entity == null)
1229+
{
1230+
return null;
1231+
}
1232+
1233+
if ((toTime != null) && (toTime.before(this.entity.getCreateTime())))
1234+
{
1235+
/*
1236+
* The entity is known - but the query time is from before the instance existed.
1237+
*/
1238+
return null;
1239+
}
1240+
1241+
/*
1242+
* The current version of the entity is in range.
1243+
*/
1244+
Map<Long, Classification> historyMap = new HashMap<>();
1245+
1246+
List<Classification> matches = getClassificationsForInclusiveDate(classificationName,
1247+
fromTime,
1248+
toTime,
1249+
this.entity.getClassifications(),
1250+
null);
1251+
1252+
if (matches != null)
1253+
{
1254+
for (Classification match : matches)
1255+
{
1256+
historyMap.put(match.getVersion(), match);
1257+
}
1258+
}
1259+
1260+
if (! this.entityHistory.isEmpty())
1261+
{
1262+
/*
1263+
* The period when an instance is active is from its updateTime to the updateTime of the next element.
1264+
* The entityHistory has the latest version first.
1265+
*/
1266+
Date followingUpdateTime = this.entity.getUpdateTime();
1267+
1268+
for (EntityDetail historicalInstance : this.entityHistory)
1269+
{
1270+
matches = getClassificationsForInclusiveDate(classificationName,
1271+
fromTime,
1272+
toTime,
1273+
this.entity.getClassifications(),
1274+
followingUpdateTime);
1275+
1276+
if (matches != null)
1277+
{
1278+
for (Classification match : matches)
1279+
{
1280+
historyMap.put(match.getVersion(), match);
1281+
}
1282+
}
1283+
1284+
followingUpdateTime = historicalInstance.getUpdateTime();
1285+
}
1286+
}
1287+
1288+
if (! historyMap.isEmpty())
1289+
{
1290+
List<Classification> historyResults = new ArrayList<>();
1291+
1292+
for (Long version : historyMap.keySet())
1293+
{
1294+
if (oldestFirst)
1295+
{
1296+
/*
1297+
* Add to the front
1298+
*/
1299+
historyResults.add(0, historyMap.get(version));
1300+
}
1301+
else
1302+
{
1303+
/*
1304+
* Add to the back
1305+
*/
1306+
historyResults.add(historyMap.get(version));
1307+
}
1308+
}
1309+
1310+
return historyResults;
1311+
}
1312+
1313+
return null;
1314+
}
1315+
1316+
11451317
/**
11461318
* Retrieve the previous version of the instance.
11471319
*
@@ -1161,7 +1333,7 @@ synchronized EntityDetail retrievePreviousVersion()
11611333
/**
11621334
* Class used to store and manage a single home classification.
11631335
*/
1164-
private class HomeClassification
1336+
private static class HomeClassification
11651337
{
11661338
volatile Classification latestClassification;
11671339
volatile long deletedVersionNumber = 0;

open-metadata-implementation/adapters/open-connectors/repository-services-connectors/open-metadata-collection-store-connectors/omrs-rest-repository-connector/src/main/java/org/odpi/openmetadata/adapters/repositoryservices/rest/repositoryconnector/OMRSRESTMetadataCollection.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,49 @@ public List<EntityDetail> getEntityDetailHistory(String userId,
10421042
}
10431043

10441044

1045+
/**
1046+
* Return all historical versions of an entity's classification within the bounds of the provided timestamps.
1047+
* To retrieve all historical versions of an entity's classification, set both the 'fromTime' and 'toTime' to null.
1048+
*
1049+
* @param userId unique identifier for requesting user.
1050+
* @param guid String unique identifier for the entity.
1051+
* @param classificationName name of the classification within entity
1052+
* @param fromTime the earliest point in time from which to retrieve historical versions of the entity (inclusive)
1053+
* @param toTime the latest point in time from which to retrieve historical versions of the entity (exclusive)
1054+
* @param startFromElement the starting element number of the historical versions to return. This is used when retrieving
1055+
* versions beyond the first page of results. Zero means start from the first element.
1056+
* @param pageSize the maximum number of result versions that can be returned on this request. Zero means unrestricted
1057+
* return results size.
1058+
* @param sequencingOrder Enum defining how the results should be ordered.
1059+
* @return {@code List<Classification>} of each historical version of the entity's classification within the bounds, and in the order requested.
1060+
* @throws InvalidParameterException the guid or date is null or fromTime is after the toTime
1061+
* @throws RepositoryErrorException there is a problem communicating with the metadata repository where the metadata collection is stored.
1062+
* @throws EntityNotKnownException the requested entity instance is not active in the metadata collection at the time requested.
1063+
* @throws EntityProxyOnlyException the requested entity instance is only a proxy in the metadata collection.
1064+
* @throws FunctionNotSupportedException the repository does not support history.
1065+
* @throws UserNotAuthorizedException the userId is not permitted to perform this operation.
1066+
*/
1067+
public List<Classification> getClassificationHistory(String userId,
1068+
String guid,
1069+
String classificationName,
1070+
Date fromTime,
1071+
Date toTime,
1072+
int startFromElement,
1073+
int pageSize,
1074+
HistorySequencingOrder sequencingOrder) throws InvalidParameterException,
1075+
RepositoryErrorException,
1076+
EntityNotKnownException,
1077+
EntityProxyOnlyException,
1078+
FunctionNotSupportedException,
1079+
UserNotAuthorizedException
1080+
{
1081+
final String methodName = "getClassificationHistory";
1082+
1083+
validateClient(methodName);
1084+
return omrsClient.getClassificationHistory(userId, guid, classificationName, fromTime, toTime, startFromElement, pageSize, sequencingOrder);
1085+
}
1086+
1087+
10451088
/**
10461089
* Return the relationships for a specific entity.
10471090
*

0 commit comments

Comments
 (0)