-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: performance issue
PostPosted: Thu Apr 28, 2016 8:16 am 
Newbie

Joined: Thu Apr 28, 2016 8:08 am
Posts: 1
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;
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.