Skip to content

Commit b335684

Browse files
committed
EntityManager: Implement method to search by uuid including removed entities
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent 3c335bd commit b335684

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

‎api/src/com/cloud/dao/EntityManager.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ public interface EntityManager {
4747
*/
4848
public <T> T findByUuid(Class<T> entityType, String uuid);
4949

50+
/**
51+
* Finds a unique entity by uuid string
52+
* @param <T> entity class
53+
* @param entityType type of entity you're looking for.
54+
* @param uuid the unique id
55+
* @return T if found, null if not.
56+
*/
57+
public <T> T findByUuidIncludingRemoved(Class<T> entityType, String uuid);
58+
5059
/**
5160
* Finds an entity by external id which is always String
5261
* @param <T> entity class

‎server/src/com/cloud/dao/EntityManagerImpl.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ public <T> T findByUuid(Class<T> entityType, String uuid) {
5151
return dao.findByUuid(uuid);
5252
}
5353

54+
@Override
55+
public <T> T findByUuidIncludingRemoved(Class<T> entityType, String uuid) {
56+
// Finds and returns a unique VO using uuid, null if entity not found in db
57+
GenericDao<? extends T, String> dao = (GenericDao<? extends T, String>)GenericDaoBase.getDao(entityType);
58+
return dao.findByUuidIncludingRemoved(uuid);
59+
}
60+
5461
@Override
5562
public <T> T findByXId(Class<T> entityType, String xid) {
5663
return null;

0 commit comments

Comments
 (0)