Yair Zaslavsky has posted comments on this change.

Change subject: core: AsyncTaskEntities - batch + get by task id
......................................................................


Patch Set 11: (10 inline comments)

....................................................
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/tasks/AsyncTaskUtils.java
Line 53:         }
Line 54:     }
Line 55: 
Line 56:     private static List<AsyncTaskEntity> buildAsyncTaskEntities(Guid 
taskId, Map<Guid, VdcObjectType> entitiesMap) {
Line 57:         List<AsyncTaskEntity> results = new ArrayList<>();
Done
Line 58:         for (Map.Entry<Guid, VdcObjectType> entry : 
entitiesMap.entrySet()) {
Line 59:             results.add(new AsyncTaskEntity(taskId, entry.getValue(), 
entry.getKey()));
Line 60: 
Line 61:         }


....................................................
File 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AsyncTaskDAODbFacadeImpl.java
Line 44:     }
Line 45: 
Line 46:     private static class AsyncTaskEntityRowMapper implements 
RowMapper<AsyncTaskEntity> {
Line 47: 
Line 48:         public static RowMapper<AsyncTaskEntity> instance = new 
AsyncTaskEntityRowMapper();
Done
Line 49: 
Line 50:         @Override
Line 51:         public AsyncTaskEntity mapRow(ResultSet rs, int rowNum) throws 
SQLException {
Line 52:             AsyncTaskEntity entity = new AsyncTaskEntity();


Line 49: 
Line 50:         @Override
Line 51:         public AsyncTaskEntity mapRow(ResultSet rs, int rowNum) throws 
SQLException {
Line 52:             AsyncTaskEntity entity = new AsyncTaskEntity();
Line 53:             
entity.setEntityId(Guid.createGuidFromString(rs.getString("entity_id")));
Done
Line 54:             
entity.setTaskId(Guid.createGuidFromString(rs.getString("async_task_id")));
Line 55:             
entity.setEntityType(VdcObjectType.valueOf(rs.getString("entity_type")));
Line 56:             return entity;
Line 57:         }


Line 50:         @Override
Line 51:         public AsyncTaskEntity mapRow(ResultSet rs, int rowNum) throws 
SQLException {
Line 52:             AsyncTaskEntity entity = new AsyncTaskEntity();
Line 53:             
entity.setEntityId(Guid.createGuidFromString(rs.getString("entity_id")));
Line 54:             
entity.setTaskId(Guid.createGuidFromString(rs.getString("async_task_id")));
Done
Line 55:             
entity.setEntityType(VdcObjectType.valueOf(rs.getString("entity_type")));
Line 56:             return entity;
Line 57:         }
Line 58:     }


Line 51:         public AsyncTaskEntity mapRow(ResultSet rs, int rowNum) throws 
SQLException {
Line 52:             AsyncTaskEntity entity = new AsyncTaskEntity();
Line 53:             
entity.setEntityId(Guid.createGuidFromString(rs.getString("entity_id")));
Line 54:             
entity.setTaskId(Guid.createGuidFromString(rs.getString("async_task_id")));
Line 55:             
entity.setEntityType(VdcObjectType.valueOf(rs.getString("entity_type")));
Saved as string in DB for readability. This has been like that for long time in 
the code - at master, save method included the following -
parameterSource.addValue("entity_type", (entityType != null) ? 
entityType.toString() : null); so you can clearly see that entity_type got a 
string value.
Line 56:             return entity;
Line 57:         }
Line 58:     }
Line 59: 


Line 114:             return 
SerializationFactory.getSerializer().serialize(params);
Line 115:         }
Line 116:     }
Line 117: 
Line 118:     private MapSqlParameterMapper<AsyncTaskEntity> mapper = new 
MapSqlParameterMapper<AsyncTaskEntity>() {
Done
Line 119: 
Line 120:         @Override
Line 121:         public MapSqlParameterSource map(AsyncTaskEntity entity) {
Line 122:             CustomMapSqlParameterSource paramSource = 
getCustomMapSqlParameterSource();


Line 121:         public MapSqlParameterSource map(AsyncTaskEntity entity) {
Line 122:             CustomMapSqlParameterSource paramSource = 
getCustomMapSqlParameterSource();
Line 123:             paramSource.addValue("task_id", entity.getTaskId()).
Line 124:                     addValue("entity_id", entity.getEntityId()).
Line 125:                     addValue("entity_type", 
entity.getEntityType().toString());
same comment as before (maybe hard a bit to follow, as save method got changed 
a bit, since in the stored proc there is no usage of INSERT SELECT + fnsplitter 
map)
Line 126:             return paramSource;
Line 127: 
Line 128:         }
Line 129:     };


Line 235:     public void insertAsyncTaskEntity(AsyncTaskEntity 
asyncTaskEntity) {
Line 236:         MapSqlParameterSource parameterSource = 
getCustomMapSqlParameterSource();
Line 237:         parameterSource.addValue("task_id", 
asyncTaskEntity.getTaskId()).
Line 238:                 addValue("entity_id", asyncTaskEntity.getEntityId()).
Line 239:                 addValue("entity_type", 
asyncTaskEntity.getEntityType());
I should fix that -should be getEntityType.toString()
Line 240:         
getCallsHandler().executeModification("InsertAsyncTaskEntities", 
parameterSource);
Line 241: 
Line 242:     }
Line 243: 


....................................................
File 
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AsyncTaskDAOTest.java
Line 280:         for (AsyncTaskEntity entity : entities) {
Line 281:             assertTrue(entities.contains(entity));
Line 282:         }
Line 283: 
Line 284:         // TODO: Missing DAO API to get all entities associated with 
a single task
Done
Line 285:     }


....................................................
File packaging/dbscripts/async_tasks_sp.sql
Line 112: CREATE OR REPLACE FUNCTION  GetAsyncTaskEntitiesByTaskId(v_task_id 
UUID)
Line 113: RETURNS SETOF async_tasks_entities
Line 114:    AS $procedure$
Line 115: BEGIN
Line 116:    RETURN QUERY SELECT * FROM async_tasks_entities
Done
Line 117:    WHERE async_task_id = v_task_id;
Line 118: END; $procedure$
Line 119: LANGUAGE plpgsql;
Line 120: 


-- 
To view, visit http://gerrit.ovirt.org/16447
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ifb4889cbc71b9beadf107430cdc0d5db3b081dea
Gerrit-PatchSet: 11
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to