Hi All,
i am working on rest web service. i did one web service deleting some records but it took much time how to reduce deleting time please guide me
@POST @ApiOperation(value = "GenericResponse", notes = "This service deletes a list of existing dataset from a project") @Path("/{projectId}/dataset/deleteDatasets") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public GenericResponse deleteMultipleDatasetsFromAProject( @ApiParam(defaultValue = "ndxis") @HeaderParam("SM_USER") String user, @PathParam("projectId") String projectId, DeleteDatasetsDTO deleteDatasetsDTO) throws Exception {
GenericResponse genericResponse = new GenericResponse();
long projectID = Long.parseLong(projectId); Long[] datasetIDs = deleteDatasetsDTO.getDatasetIds(); boolean validateDatasetstoProject = false; for (long n : datasetIDs) { validateDatasetstoProject = projectManagmentDelegate .validateProjectDatasetbyId(projectID, n); if (!(validateDatasetstoProject)) throw new OtherValidationException(Constants.INVALID_DATASET_ID); }
boolean result = false; result = projectManagmentDelegate.deleteDatasetsFromAProject( datasetIDs, projectID);
if (result) { genericResponse.setMessage(Constants.DATASETS_DELETE_SUCCESS); } else { genericResponse.setMessage(Constants.DATASETS_DELETE_FAILURE); }
return genericResponse; }
@Transactional public boolean deleteDatasetsFromAProject(Long[] datasetList, long projectId) throws IntegrationStudioRepositoryException { boolean result = false; if (dataSetRepository.removeMultiple(datasetList)) result = updateProjectTimestampToCurrent(projectId); return result; }
@Transactional public boolean updateProjectTimestampToCurrent(long projectId) throws IntegrationStudioRepositoryException {
return projectRepository.updateTimestamp(projectId); }
public Boolean removeMultiple(Long[] datasetList) throws IntegrationStudioRepositoryException { Boolean status = false; Session session = sessionFactory.getCurrentSession();
for (long n : datasetList) { InputDatasetModel anObject = (InputDatasetModel) session.load( InputDatasetModel.class, n);
if (anObject != null) { session.delete(anObject); status = true; } }
return status; }
|